A lightweight fabric defect multi-scale detection method and system
By generating high-quality defect images using the DA-StyleGAN model and constructing the YOLO-RG detection model, the accuracy problem of small-scale fabric defect identification was solved, and efficient fabric defect detection was achieved under environments with limited computing power.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG SCI-TECH UNIV
- Filing Date
- 2026-03-06
- Publication Date
- 2026-06-26
AI Technical Summary
Existing technologies cannot accurately identify small-scale fabric defects, and the computing power of equipment is limited in industrial deployments, making it difficult to achieve efficient and reliable detection.
Data augmentation is performed using the DA-StyleGAN model to generate high-quality defect images. A YOLO-RG detection model is also constructed. Lightweight designs such as C3K2-EMC, RepMixCE, and LSPD are used to optimize the model's feature extraction network and reduce computational resource consumption.
It enables accurate identification of minute and multi-scale defects in industrial settings, optimizes detection accuracy and speed, and adapts to environments with limited equipment computing power.
Smart Images

Figure CN121810668B_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 multi-scale detection of defects in lightweight fabrics. Background Technology
[0002] Fabric defect detection is a core component of digital quality control in the textile industry, playing a crucial role in ensuring product quality and production efficiency. As the industry continues to raise its requirements for quality standards and production efficiency, developing efficient and reliable automated detection technologies has become an important direction for industrial upgrading.
[0003] Thanks to the rapid development of computer hardware and deep learning theory, the field of machine learning has made groundbreaking progress, driving the widespread application of advanced models, represented by neural networks, in image recognition. Against this backdrop, deep learning-based object detection technology offers a new approach to the intelligent identification of fabric defects. The YOLO series of models, due to their excellent balance between detection speed and accuracy, has been successfully introduced into this field. Among them, the YOLOv11 model demonstrates strong environmental adaptability, efficiency, and detection accuracy, becoming a potential tool for promoting industrial automated inspection and providing effective support for technological advancements in the industry.
[0004] However, when dealing with complex fabric textures, how to more accurately identify small-scale defects and further optimize the model to adapt to the computing-constrained deployment environment common in industrial settings remains a direction worth exploring. Summary of the Invention
[0005] In view of the shortcomings of the prior art, the purpose of this invention is to provide a lightweight fabric defect multi-scale detection method that can solve the technical problems of the prior art being unable to accurately identify small-scale defects and the limited computing power of equipment in industrial deployment.
[0006] A first aspect of this invention provides a multi-scale defect detection method for lightweight fabrics, comprising:
[0007] S1: Acquire fabric images, which include images of fabric defects and images of fabric without defects;
[0008] S2: Preprocess the fabric images to obtain the initial dataset;
[0009] S3: The DA-StyleGAN model is used to perform data augmentation on the preprocessed defect image to generate an enhanced defect image;
[0010] S4: Merge the enhanced defect images with the initial dataset to form the final training dataset;
[0011] S5: Construct the YOLO-RG detection model;
[0012] S6: Input the final training dataset into the YOLO-RG detection model to train the YOLO-RG detection model;
[0013] S7: Acquire an image of the fabric to be detected;
[0014] S8: Input the image of the fabric to be detected into the trained YOLO-RG detection model and output the detection results.
[0015] A second aspect of the present invention provides a lightweight fabric defect multi-scale detection system, comprising: a processor and a memory;
[0016] The memory stores programs or instructions that can run on the processor, which, when executed by the processor, implement the steps of the lightweight fabric defect multi-scale detection method as described in the first aspect.
[0017] 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 lightweight fabric defect multi-scale detection method as described in the first aspect.
[0018] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following:
[0019] In this embodiment of the invention, to address the shortcomings of existing technologies that easily miss small defects, a generative model-based enhancement process is applied to the training dataset, and the model's feature extraction network is optimized, effectively strengthening the extraction and identification capabilities of small and multi-scale defect features. Simultaneously, to address the limitation of equipment computing power in industrial deployments, a lightweight design is systematically introduced into the model's neck network and detection head, significantly reducing the overall complexity of the model and computational resource consumption. Ultimately, this algorithm achieves an optimized balance between accuracy, speed, and lightweight design throughout the complete detection process, providing an efficient and reliable solution for the practical deployment and application of fabric defect detection technology in industrial scenarios. Attached Figure Description
[0020] 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.
[0021] Figure 1 This is a flowchart illustrating a multi-scale defect detection method for lightweight fabrics provided in an embodiment of the present invention.
[0022] Figure 2 This is a schematic diagram of a C3K2_EMC module provided in an embodiment of the present invention.
[0023] Figure 3 This is a schematic diagram of a RepMixCE module provided in an embodiment of the present invention.
[0024] Figure 4 This is a schematic diagram of a RepBlock module provided in an embodiment of the present invention.
[0025] Figure 5 This is a schematic diagram of the structure of a CSPNet module and an ELAN module provided in an embodiment of the present invention.
[0026] Figure 6 This is a schematic diagram of a high-performance, lightweight detection head LSPD structure provided in an embodiment of the present invention.
[0027] Figure 7 This is a network diagram of the YOLO-RG algorithm for a multi-scale defect detection method for lightweight fabrics provided in an embodiment of the present invention.
[0028] Figure 8 This is a schematic diagram of the structure of a lightweight fabric defect multi-scale detection system provided in an embodiment of the present invention. Detailed Implementation
[0029] 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.
[0030] The multi-scale defect detection method for lightweight fabrics provided by the present invention will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.
[0031] Reference manual attached Figure 1 The diagram shows a flowchart of a multi-scale defect detection method for lightweight fabrics provided by an embodiment of the present invention.
[0032] This invention provides a multi-scale defect detection method for lightweight fabrics, which may include the following steps:
[0033] S1: Acquire fabric images, which include images of fabric defects and images of fabric without defects.
[0034] Among them, fabric images refer to images that include the surface texture and state of fabrics, defect images are fabric images with defects such as weft shrinkage and holes, and defect-free images are fabric images with no surface defects.
[0035] Specifically, the data collection can be carried out in actual production environments, and the collected fabrics cover a variety of texture types and defects include a variety of common defect types, ensuring that the original data covers common industrial production scenarios.
[0036] For example, the original pixel size of the acquired image is 6000×4000. Both defect-free and defective samples are captured simultaneously.
[0037] For example, to facilitate model learning, the self-built dataset is uniformly categorized into four textures: herringbone twill fabric, star pattern twill fabric, checkered plain weave fabric, and plain linen fabric, as well as six defects: weft shrinkage, holes, knots, stains, broken yarns, and loose threads.
[0038] S2: Preprocess the fabric image to obtain the initial dataset.
[0039] Preprocessing refers to operations such as rotation correction, region of interest selection, annotation, and format standardization of the original fabric image. The initial dataset is a preprocessed dataset containing the image and corresponding defect annotation information.
[0040] Specifically, preprocessing can remove interfering factors from the image, filter out core areas, and provide high-quality basic data for subsequent processing.
[0041] For example, all images in the dataset are resized to 1024×1024 pixels with a color depth of 24 bits, thus completing the unified formatting of the region of interest and label files.
[0042] In one possible implementation, S2 specifically includes sub-steps S201 to S204:
[0043] S201: Remove background clutter and edge interference from the fabric image through rotation correction.
[0044] Among them, rotation correction is a processing method that adjusts the angle of the fabric image to correct the shooting offset, and the region of interest refers to the core image area containing defect features or effective fabric texture.
[0045] Specifically, this operation can correct image pose deviations, initially purify image content, and reduce the impact of irrelevant factors on subsequent processing.
[0046] It should be noted that this operation can eliminate noise introduced by non-target areas, providing a uniform image basis for subsequent feature analysis and improving processing consistency.
[0047] S202: Perform a selection operation on the rotated image to retain the region of interest containing defect features or effective fabric texture.
[0048] Among them, the region of interest refers to the core part of the image containing key information, the defect feature refers to the visual features that can reflect defects, and the effective texture refers to the typical texture of the fabric itself.
[0049] Furthermore, by selecting regions of interest, core information can be focused on, reducing the amount of data to be processed subsequently and improving processing efficiency.
[0050] It should be noted that by extracting this area, computing resources can be focused on effective content, eliminating irrelevant background interference, thereby improving the efficiency and targeting of subsequent processing.
[0051] S203: Using the Labelimg annotation tool, mark the defects in the region of interest according to the YOLO data format, and generate a label file containing defect type and location information.
[0052] Among them, Labelimg is a commonly used target detection data annotation software, YOLO data format is an annotation file format adapted to YOLO series models, and label file is a file that records the type and location information of defects.
[0053] It should be noted that this step provides accurate ground truth data for supervised learning, which is a fundamental prerequisite for the model to learn localization and classification tasks.
[0054] S204: Based on the preset image size and color depth, uniformly format the region of interest and label files to construct the initial dataset.
[0055] The preset image size and color depth are uniform specifications for adapting model training (e.g., 1024×1024 pixels, 24 bits), and the initial dataset is a set of preprocessed and standardized images and labels.
[0056] It should be noted that those skilled in the art can set the preset image size according to actual needs, and this invention does not limit that.
[0057] For example, all images can be uniformly adjusted to a specific pixel size and the color depth can be set to a fixed number of bits to ensure that the data format meets the requirements for model reading and processing.
[0058] It should be noted that this operation ensures the consistency of the data input dimensions, which is a key step in achieving stable batch training and efficient memory utilization.
[0059] In this embodiment of the invention, by removing background clutter and edge interference, and standardizing the image size (1024×1024 pixels) and color depth (24 bits), the impact of noise on model training is reduced. At the same time, the standardized data format facilitates subsequent model reading and processing, thereby improving training efficiency.
[0060] S3: The DA-StyleGAN model is used to perform data augmentation on the preprocessed defect images to generate enhanced defect images.
[0061] Among them, the DA-StyleGAN model is an image generation model based on defect-aware residual masks. Data augmentation refers to the operation of expanding the dataset by generating new samples to enhance the defect images into high-quality, feature-realistic defect images generated by the model.
[0062] For example, the mask image is made at 1024×1024 dpi with an 8-bit color depth. Maintaining consistent sample image size and texture orientation facilitates information retrieval by the DA-StyleGAN network model.
[0063] It should be noted that the defect images generated by this model have realistic features, which can effectively make up for the problem of insufficient number of original defect samples.
[0064] In one possible implementation, S3 specifically includes sub-steps S301 to S304:
[0065] S301: Design a defect-aware residual mask for the preprocessed defect image and generate mask information for controlling the synthesis.
[0066] Among them, the defect-aware residual mask is a binary image used to indicate the precise location and shape of defects.
[0067] Specifically, this mask can precisely control the generation position of defects in the image, ensuring that the generated defects conform to the actual distribution pattern.
[0068] It should be noted that this mask provides spatial guidance for the generative model, ensuring that the shape and position of the generated content conform to the distribution pattern of real defects.
[0069] S302: Based on the mask information, the preprocessed defect image is augmented using the DA-StyleGAN model to generate an augmented defect image.
[0070] Among them, the DA-StyleGAN model is a generative adversarial network that incorporates data augmentation strategies.
[0071] Specifically, the DA-StyleGAN model uses the provided mask information to generate high-quality images that are similar to the visual features of real defects at specified locations.
[0072] Specifically, the model uses mask information as a constraint, and the generated augmented defect images are highly consistent with the real defects in terms of visual features.
[0073] It should be noted that this step, guided by the mask, can synthesize high-quality new samples that retain the real defect features while also having background diversity.
[0074] S303: Based on the DA-StyleGAN model, pixel-level mask images corresponding to the expanded defect images are generated synchronously to form expanded defect image-pixel-level mask image data pairs.
[0075] Among them, the pixel-level mask image is a segmentation label image accurate to the pixel level.
[0076] It should be noted that synchronous mask generation ensures that the augmented data has detailed annotation information, which is beneficial for the model to learn more accurate defect contours and detailed features.
[0077] S304: According to the preset verification process, the validity of the augmented defect image-pixel-level mask image data pair is verified using the YOLOv11n model, and the enhanced defect images that pass the verification are selected.
[0078] Among them, validity verification refers to the automated evaluation of the quality of generated samples using a benchmark detection model.
[0079] Furthermore, a benchmark model (such as YOLOv11n) is used to automatically evaluate the quality of the generated data, and high-quality generated samples that are correctly identified by the model are selected to ensure the effectiveness of the augmented data.
[0080] Furthermore, this verification step can filter out augmented data with authentic features that meet the requirements, thus avoiding invalid data from affecting the model training effect.
[0081] It should be noted that this filtering mechanism can filter out low-quality or undesirable generated samples, thereby ensuring the reliability and effectiveness of the dataset used for training.
[0082] In this embodiment of the invention, the defect perception residual mask is used to control the position and shape of the defect synthesis. The generated enhanced defect image features are realistic and have high visual consistency with the real defect. After the effectiveness is verified by YOLOv11n, it can effectively make up for the problem of insufficient number of original defect samples and enrich the diversity and coverage of the dataset.
[0083] S4: Merge the enhanced defect images with the initial dataset to form the final training dataset.
[0084] The final training dataset refers to the comprehensive training data set that integrates the initial dataset with effectively enhanced defect images (including associated pixel-level mask images).
[0085] Furthermore, the original fabric data is combined with the generated fabric data to construct an expanded fabric dataset for the detection of fabric defects in the model.
[0086] Furthermore, this dataset combines the authenticity of the original data with the diversity of the augmented data, providing ample and comprehensive sample support for model training.
[0087] In this embodiment of the invention, by integrating the original preprocessed data with high-quality augmented data, the scale and diversity of the dataset are improved, providing a sufficient data foundation for the model to learn multi-scale and multi-type defect features, and helping to improve the model's generalization ability and detection accuracy.
[0088] S5: Construct the YOLO-RG detection model.
[0089] The YOLO-RG detection model is a lightweight model based on the improved YOLOv11n, which includes four core modules: input, backbone network, neck network, and detection head. The core improved modules include C3K2-EMC, RepMixCE, and LSPD.
[0090] The YOLO-RG detection model is a fabric defect detection model based on the improved YOLOv11n. It consists of four core parts: input, backbone network, neck network, and detection head. The enhanced defect images are high-quality, feature-realistic defect images generated by the DA-StyleGAN model. The final training dataset is a comprehensive training data set that integrates the initial dataset and the enhanced defect images.
[0091] Specifically, these operations are linked together to form a complete multi-scale feature extraction process, ensuring that the module can capture defect features at different scales.
[0092] Specifically, the model achieves synergy between multi-scale feature extraction and lightweight design through optimized design of each core module.
[0093] It should be noted that this hierarchical design clarifies the functional division of each module, forming a highly efficient and collaborative testing pipeline.
[0094] The backbone network, neck network, and detection head together constitute the core architecture for feature extraction, fusion, and prediction in the target detection model.
[0095] Specifically, the backbone network of the YOLO-RG detection model uses the C3K2-EMC module instead of the traditional C3K2 module as the feature extraction network, the neck network is designed with the reparameterized RepMixCE module, and the detection head adopts the lightweight detection head LSPD that integrates shared convolution, adaptive scale layer and group normalization.
[0096] It should be noted that this hierarchical design clarifies the functional division of each module, forming a highly efficient and collaborative testing pipeline.
[0097] Optionally, the YOLO-RG detection model includes an input terminal, a backbone network, a neck network, and a detection head connected in sequence.
[0098] The backbone network consists of multiple C3K2-EMC modules connected in sequence.
[0099] Among them, the C3K2-EMC module is a lightweight building block for basic feature extraction in the backbone network.
[0100] It should be noted that using this module can effectively control the computational complexity of the model in the early stages while extracting rich features.
[0101] The C3K2-EMC module is constructed by stacking multiple Bottleneck_EMC basic units, with the EMConv module as the core component of the Bottleneck_EMC basic unit.
[0102] Among them, the Bottleneck_EMC basic unit is a residual unit with a bottleneck structure design, and EMConv is the core operator that performs feature transformations internally.
[0103] Reference manual attached Figure 2 The diagram shows a C3K2_EMC module provided in an embodiment of the present invention.
[0104] Specifically, Figure 2 The key parameters and layer structures involved include: EMConv, the efficient multi-scale convolutional module, which is the basic operator that constitutes the core unit; Input represents the input feature map; Conv, the standard convolutional layer, is used for basic feature transformation; Add is the element-wise addition operation, used for feature fusion; Bottleneck_EMC is an improved bottleneck residual unit with EMConv as its core; and C3k_EMC is a core functional module composed of multiple Bottleneck_EMC units stacked together, used to replace the corresponding structure in the original network.
[0105] Furthermore, the Figure 2The inclusion relationship is specifically manifested as follows: the C3k_EMC module, as a whole, contains multiple sequentially connected Bottleneck_EMC basic units. Each Bottleneck_EMC unit contains two Conv layers and one EMConv module. The EMConv module integrates its own input, convolutional layers, and a feature reorganization mechanism implemented through the Add operation. From the connection relationship, the data flow processing is clear and explicit: within a single Bottleneck_EMC unit, the input first enters the first Conv layer for preliminary processing; its output, along with the features deeply extracted by the internal EMConv module, is fused through the Add operation to form the output of that unit. In higher-level C3k_EMC modules, the output of the previous Bottleneck_EMC unit is directly used as the input of the next Bottleneck_EMC unit, and so on, forming a deep feature extraction chain.
[0106] It should be noted that, Figure 2 The C3K2-EMC module shown embeds lightweight, efficient multi-scale convolutions into residual bottleneck units and stacks them in a modular fashion. This significantly controls the number of parameters while giving the backbone network a powerful multi-scale feature extraction capability, thus laying a solid foundation for the subsequent accurate detection of fabric defects of various scales (especially tiny ones).
[0107] It should be noted that by stacking this unit, the nonlinear expressive power can be enhanced with lower parameter cost when deepening the network.
[0108] The neck network consists of multiple RepMixCE modules connected in sequence. The RepMixCE modules are connected through a dual-path structure. The main path integrates a RepBlock sub-module that uses reparameterization technology. The dual-path structure fuses the features processed by the RepBlock sub-module with the original shortcut path features.
[0109] Among them, the RepMixCE module is the key module in the neck network responsible for multi-scale feature fusion, and RepBlock is a reparameterizable building block inside it used to improve efficiency.
[0110] It should be noted that the dual-path structure of the RepMixCE module is inspired by the splitting approach of CSPNet. The main path is responsible for feature transformation and processing, while the shortcut path retains the original feature information. The fusion of the two achieves cross-stage information complementarity.
[0111] Furthermore, the RepBlock submodule integrated in the main path is a structure that employs reparameterization techniques to improve the efficiency of training and inference.
[0112] Reference manual attached Figure 3 The diagram shows a schematic of a RepMixCE module provided in an embodiment of the present invention.
[0113] Specifically, in Figure 3 In the diagram, Input represents the input feature map of the RepMixCE module, which is the initial processing data for this module; Conv1×1 represents a 1×1 convolutional layer used to adjust the channel dimension of the feature map; Split represents the channel splitting operation module used to divide the feature map into different processing branches; RepBlock represents a convolutional module using reparameterization technology, which is the core feature processing unit in the main path of this module; Conv3×3 represents a 3×3 convolutional layer used to extract local detail features of the feature map, where "n-1" represents the number of times the convolutional layer is stacked; ConCat represents the feature concatenation module used to fuse feature information from different branches; and the final Conv1×1 is also a 1×1 convolutional layer used to integrate the concatenated features and output the final result.
[0114] Furthermore, Figure 3 The inclusion relationship is as follows: the RepMixCE module contains a Conv1×1 layer, a Split module, a RepBlock module, n-1 Conv3×3 layers, and a ConCat module; the main path processing branch contains a RepBlock module, n-1 sequentially connected Conv3×3 layers and their corresponding Conv1×1 layers. Figure 3 The connection relationships clearly demonstrate the characteristic processing flow of the RepMixCE module: Input is first connected to the Conv1×1 layer; the output of the Conv1×1 layer is connected to the Split module; the output of the Split module is split into two paths, one connected to the RepBlock module and the other directly connected to the ConCat module; the output of the RepBlock module is connected to the first Conv3×3 layer, and the subsequent n-1 Conv3×3 layers are connected in series (the output of the previous Conv3×3 is connected to the next Conv3×3); the output of the last Conv3×3 layer is connected to the Conv1×1 layer; the output of this Conv1×1 layer and the other output from the Split module are connected to the ConCat module; the output of the ConCat module is connected to the last Conv1×1 layer, which serves as the final output of the RepMixCE module.
[0115] It should be noted that, Figure 3The RepMixCE module shown here, through its gradient splitting dual-path structure, reparameterized RepBlock module, and collaborative design of multiple sets of convolutional layers, effectively integrates multi-scale fabric defect features while reducing computational and parameter requirements, thereby improving the completeness of feature representation and detection accuracy, and adapting to the lightweight detection needs of industrial scenarios.
[0116] It should be noted that this design achieves efficient complementarity and aggregation of deep semantic features and shallow detailed features through cross-path information fusion.
[0117] Optionally, the EMConv module achieves multi-scale feature extraction by sequentially performing channel segmentation, tensor reshaping, multi-scale convolution extraction, and feature splicing and fusion.
[0118] It should be noted that, through the design of grouped parallel processing and heterogeneous convolutional kernels, this module can integrate multi-scale receptive fields within a single layer, thereby enhancing the ability to capture features of targets with varying sizes.
[0119] The feature map input to the C3K2-EMC module is divided into preset parts along the channel dimension through channel segmentation:
[0120] ;
[0121] in, X This represents the input feature map of the EMConv module. C Represents the input feature map X Total number of channels split This indicates a channel splitting operation. Indicates the division ratio. dim =1 indicates that the segmentation operation is performed along the channel dimension. X cheap This represents the branch feature map that retains the underlying basic features after segmentation. X group This represents the branch feature map used for multi-scale feature extraction.
[0122] The channel segmentation operation divides the input feature map into two channel subsets.
[0123] The channel segmentation operation divides the input feature map into two parts. One part is directly retained to maintain low-level features (called the Cheap branch), and the other part is used for multi-scale feature extraction (called the Group branch).
[0124] It should be noted that this operation achieves feature splitting, with one part used to preserve the original information and the other part used for more complex multi-scale transformations.
[0125] Through tensor reshaping, the segmented feature maps are divided into multiple groups along the channel dimension:
[0126] ;
[0127] in, R This indicates a tensor reshaping operation. This represents the reshaped target dimension. B Indicates batch size. G Indicates the number of groups. This represents the number of channels in each feature map group. H Indicates the height of the feature map. W Indicates the width of the feature map.
[0128] Among them, the tensor reshaping operation changes the dimensional organization of the feature tensor.
[0129] Specifically, the tensor reshaping operation alters the dimensional organization of the Group branch feature map, dividing it into multiple independent groups along the channel dimension.
[0130] It should be noted that this operation organizes the feature channels into multiple independent groups, creating the conditions for applying convolutional kernels of different sizes to each group independently.
[0131] Based on the grouped feature maps, perform multi-scale convolution extraction operations:
[0132] ;
[0133] in, Conv ki This represents the convolution operation. i Indicates a grouped index. k i Indicates the first i The heterogeneous kernel size used by the group Y i Indicates the first i The output feature map after group convolution.
[0134] Among them, multi-scale convolution extraction operation refers to using convolution kernels of different sizes to extract features for each group.
[0135] Furthermore, by configuring heterogeneous convolutional kernels, each group can focus on extracting defect features at the corresponding scale, thereby improving the comprehensiveness of feature extraction.
[0136] It should be noted that this operation allows the model to capture contextual information in parallel across different spatial ranges, enriching the scale diversity of features.
[0137] Based on the extracted multi-scale features, a multi-scale fused feature map output by the EMConv module is generated through feature concatenation and fusion operations:
[0138] ;
[0139] in, This indicates a feature concatenation operation. Y group This represents the multi-scale fused feature map that is ultimately output by the Group branch.
[0140] The feature splicing and fusion operation re-merges the features extracted from each parallel branch.
[0141] Furthermore, the feature splicing and fusion operation re-splices the multi-scale features extracted from each group along the channel dimension to form an enhanced feature map that integrates multi-scale information.
[0142] It should be noted that this operation integrates feature responses at different scales into a unified enhanced feature representation, providing more comprehensive information for subsequent layers.
[0143] Optionally, the construction process of the RepBlock submodule specifically includes:
[0144] During the model training phase, the RepBlock submodule is constructed as a structure containing multiple parallel convolutional branches.
[0145] Parallel convolution branches refer to the use of multiple paths with different convolution kernels to process the input in parallel during training.
[0146] Specifically, multi-branch structures can enrich the dimensions of feature extraction and improve the model's feature learning ability during the training phase.
[0147] It should be noted that this design improves the model's feature representation ability and optimization flexibility during the training phase.
[0148] The feature maps input to the RepBlock submodule are then processed by multiple parallel convolutional branches.
[0149] The feature maps of each parallel convolutional branch are processed using batch normalization:
[0150] ;
[0151] in, W ( x () represents the convolution operation. x Indicates the input feature map, mean This represents the mean of the batch normalized layer statistics. This represents the standard deviation of the batch normalized stratum statistics. This represents the learnable scaling factor of the batch normalization layer. β This represents the offset factor of the batch normalization layer.
[0152] Batch normalization is a technique that accelerates training and improves stability by normalizing the layer input.
[0153] Specifically, batch normalization (BN) is applied to the output features of each convolutional branch to stabilize the training process and accelerate convergence.
[0154] Specifically, this operation can reduce the impact of feature value fluctuations on training, making model training more stable and efficient.
[0155] It should be noted that this operation can alleviate the internal covariate shift problem, making the training process smoother and faster.
[0156] During the model inference phase, multiple parallel convolutional branches and their corresponding batch normalization layers are merged into a single convolutional operation through reparameterization techniques.
[0157] Among them, reparameterization refers to the method of converting the complex multi-branch structure during training into a single linear structure during inference.
[0158] Furthermore, this technology can reduce the computational complexity and memory usage during the inference phase without sacrificing model performance.
[0159] It should be noted that reparameterization is a method that converts a complex multi-branch structure during training into a single linear structure during inference.
[0160] Based on equivalent weights and equivalent biases, a single convolution operation is performed on the feature map, outputting the feature map after processing by the RepBlock submodule.
[0161] Among them, equivalent weight and equivalent bias refer to the single-branch learnable parameters formed after the fusion of multi-branch and batch normalization layers, and feature data refers to multi-dimensional data that carries feature information.
[0162] Among them, equivalent weights and equivalent biases are obtained by mathematically fusing and algebraically transforming the parameters of the convolutional layers and BN layers of the above multiple branches through reparameterization techniques.
[0163] Specifically, this processing method can quickly output high-quality feature data, ensuring the efficiency of model inference.
[0164] Reference manual attached Figure 4 The diagram shows a RepBlock module provided in an embodiment of the present invention.
[0165] Specifically, in Figure 4In the diagram, 3×3 (convlayer) represents a convolutional layer with a kernel size of 3×3, which is the core layer for feature extraction; 1×1 represents a convolutional layer with a kernel size of 1×1, used to adjust the feature channel dimension; BNlayer represents a batch normalization layer, used to stabilize the training gradient; aparameter represents an effective parameter, which is the parameter value that participates in feature calculation; azerovalue represents a zero-value parameter, which is an invalid parameter filled in during reparameterization; convparameters represents the parameter set of the convolutional layer; BNparameters represents the parameter set of the batch normalization layer; (A) Perspectiveofstructure is the structural perspective of the RepBlock module, and (B) Perspectiveofparameter is the parameter perspective of the RepBlock module.
[0166] Furthermore, Figure 4 The inclusion relationship is as follows: The RepBlock module (from a structural perspective) contains multiple sets of parallel convolutional layers (3×3, 1×1) and corresponding BN layers, which are eventually merged into a 3×3 convolutional layer; The RepBlock module (from a parameter perspective) contains the set of convolutional layer parameters and the set of batch normalization layer parameters, which together participate in the reparameterization calculation. Figure 4 The connections clearly demonstrate the reparameterization process of the RepBlock module: From a structural perspective, the input is first connected to parallel 3×3 convolutional layers and 1×1 convolutional layers, and the output of each convolutional layer is connected to the corresponding BN layer; the outputs of these parallel branches are fused and then connected to the final 3×3 convolutional layer; From a parameter perspective, the convolutional layer parameters and batch normalization layer parameters are calculated through reparameterization and fused into the final 3×3 convolutional layer parameters, which include effective parameters and zero-value parameters.
[0167] It should be noted that, Figure 4 The RepBlock module shown improves the accuracy of fabric defect feature extraction by using a multi-branch structure combined with BN layers during the training phase, and reparameterizes it into a single convolutional layer during the inference phase. This reduces computational and memory usage while maintaining detection performance, making it suitable for the industrial deployment needs of lightweight fabric defect detection.
[0168] In one possible implementation, S5 specifically includes sub-steps S501 to S508:
[0169] S501: Input for building the YOLO-RG detection model.
[0170] The input module is the entry point for the model to receive and initially process the raw image data.
[0171] Specifically, this module can adapt to preset image sizes and color depths, providing standardized input for subsequent feature extraction.
[0172] It should be noted that this module is responsible for importing data and performing basic format conversions, preparing standardized inputs for the subsequent feature extraction process.
[0173] S502: Based on the image data received at the input end, build the backbone network of the YOLO-RG detection model.
[0174] The backbone network is the core component of the model for deep feature extraction.
[0175] Specifically, the backbone network is constructed by connecting multiple C3K2-EMC modules in sequence, and is responsible for extracting multi-level features from the image.
[0176] It should be noted that by building this network, multi-level, highly semantic abstract features can be gradually extracted from the input image.
[0177] S503: Performs multi-scale feature extraction on image data by configuring the C3K2-EMC module in the backbone network.
[0178] The C3K2-EMC module is a key component in the backbone network for achieving efficient feature extraction.
[0179] Specifically, this module can reduce computational costs while enhancing the feature representation of minor defects and improving the comprehensiveness of feature extraction.
[0180] It should be noted that configuring the C3K2-EMC module enables the backbone network to efficiently extract and fuse multi-scale features, enhancing its ability to capture minute defects.
[0181] S504: Based on multi-scale features, a neck network for the YOLO-RG detection model is constructed.
[0182] The neck network is the feature fusion and enhancement part that connects the backbone network and the detection head.
[0183] Furthermore, the neck network is constructed by sequentially connecting multiple RepMixCE modules, which are responsible for fusing features from different levels of the backbone network.
[0184] It should be noted that the purpose of building this network is to efficiently aggregate features and complement information at different levels.
[0185] S505: Feature fusion is performed on gradient splitting and multi-scale fusion mechanisms by configuring the RepMixCE module in the neck network.
[0186] The RepMixCE module achieves efficient feature fusion through two mechanisms: gradient splitting and multi-scale fusion.
[0187] Furthermore, the gradient splitting mechanism draws inspiration from CSPNet, employing a dual-path structure: the main path performs feature transformation, while the shortcut path preserves the original features, thereby reducing computational redundancy and improving gradient flow. The multi-scale fusion mechanism adopts the design principles of ELAN, combining shallow features containing details with semantically rich deep features through cross-layer or cross-path feature aggregation. In the RepMixCE module, both mechanisms are designed in a unified manner: the gradient splitting structure forms the basic processing framework, and multi-scale fusion completes cross-layer information integration within this framework. Ultimately, this module enhances the model's ability to represent features of multi-scale defects (especially small objects) while maintaining operational efficiency.
[0188] Reference manual attached Figure 5 The diagram shows a structural schematic of a CSPNet module and an ELAN module provided in an embodiment of the present invention.
[0189] Specifically, in Figure 5 In the diagram, Input represents the input feature map of the module, which is the initial processing data for both types of modules; Conv1×1 represents a convolutional layer with a kernel size of 1×1, used to adjust the channel dimension of the feature map; Split represents the channel splitting operation module, used to divide the feature map into different processing branches; Bottleneck represents the bottleneck layer, which is the feature compression and extraction unit in CSPNet, and "N" represents the number of times the bottleneck layer is stacked and repeated; ConCat represents the feature concatenation module, used to fuse feature information from different branches; Conv3×3 and Conv5×5 represent convolutional layers with kernel sizes of 3×3 and 5×5, respectively, used to extract feature details at different scales; CSPNet and ELAN are two types of feature processing modules, corresponding to the upper and lower structures in the diagram, respectively.
[0190] Furthermore, Figure 5 The inclusion relationships are as follows: the CSPNet module contains a Conv1×1 layer, a Split module, N Bottleneck layers, a ConCat module, and multiple Conv1×1 layers; the ELAN module contains multiple Conv1×1 layers, a Conv3×3 layer, a Conv5×5 layer, and a ConCat module. Figure 5The connection relationships clearly illustrate the feature processing flow of the two types of modules: In CSPNet, the Input is first connected to the Conv1×1 layer; the output of the Conv1×1 layer is connected to the Split module; the output of the Split module is split into two paths, one path connects to N sequentially connected Bottleneck layers, the output of the last Bottleneck layer of this path connects to the Conv1×1 layer, and the other path directly connects to the ConCat module; the output of the Conv1×1 layer after the Bottleneck layer and the other output from the Split module are both connected to the ConCat module; the output of the ConCat module is connected to the final Conv1×1 layer. In ELAN, the Input is split into two paths, one path connects to the Conv1×1 layer, the output of which is sequentially connected to the Conv3×3, Conv3×3, Conv3×3, and Conv5×5 layers; the other path directly connects to the ConCat module; the output of the last convolutional layer (Conv5×5) and the other output from the Input module are both connected to the ConCat module; the output of the ConCat module is connected to the final Conv1×1 layer.
[0191] It should be noted that, Figure 5 The CSPNet shown reduces computation and enhances feature learning capabilities through channel splitting, while ELAN expands the receptive field and retains multi-scale information through multi-scale convolutional layers. Together, they provide efficient feature processing support for fabric defect detection, improving the recognition accuracy of defects of different sizes while reducing model complexity.
[0192] Among them, the RepMixCE module is the core unit in the neck network that integrates the ideas of reparameterization and multi-scale fusion.
[0193] Specifically, the RepMixCE module utilizes its dual-path structure to deepen features through the main path on the one hand, and retain shallow details through the shortcut path on the other, achieving efficient feature fusion.
[0194] Specifically, this module enables cross-stage information complementarity, expanding the receptive field while maintaining the integrity of multi-scale information.
[0195] It should be noted that configuring this module can achieve deep fusion and enhancement of cross-level features with low computational cost.
[0196] S506: Based on the fusion features of the neck network after fusion, a detection head for the YOLO-RG detection model is built.
[0197] The detection head is the output part of the model that ultimately performs target localization and classification prediction.
[0198] It should be noted that this module is designed to map high-level semantic features to specific defect locations and category information.
[0199] S507: By configuring a lightweight inspection head LSPD in the inspection head, it outputs inspection features for defect location and classification.
[0200] Among them, the Lightweight Detection Head LSPD is a high-efficiency prediction head that employs shared computing and adaptive mechanisms.
[0201] Specifically, this detection head can improve the detection performance of multi-scale defects while reducing parameters and computational load.
[0202] It should be noted that the lightweight inspection head LSPD uses techniques such as shared convolution, adaptive scale layer and group normalization to improve the detection performance of multi-scale defects while compressing parameters.
[0203] In one possible implementation, S507 specifically includes sub-steps S5071 to S5074:
[0204] S5071: Based on the fusion features after neck network fusion, a shared convolution strategy is used to merge multi-branch detection heads into a single shared convolution branch.
[0205] Among them, the shared convolution strategy refers to multiple detection branches sharing the same set of convolution parameters for feature processing.
[0206] It should be noted that this strategy can effectively reduce the number of model parameters, improve computational efficiency, and enhance the consistency of features between different branches.
[0207] S5072: Based on the shared features output by a single shared convolutional branch, the feature scale is adjusted through an adaptive scale layer.
[0208] The adaptive scale layer is a feature transformation layer that can learn scaling factors.
[0209] Specifically, the adaptive scale layer can learn and apply a scale scaling factor to dynamically adjust the response intensity of the feature map to better adapt to defect targets of different sizes.
[0210] Specifically, this layer can adapt to defect features of different sizes, especially improving the detection capability of small target defects.
[0211] It should be noted that this layer can dynamically adjust the feature response intensity, thereby improving the model's sensitivity to the detection of targets at different scales, especially small defects.
[0212] S5073: Process the adjusted shared features through group normalization operation.
[0213] Among them, group normalization is a stabilization technique that groups channels and then normalizes them.
[0214] Furthermore, this operation can enhance the robustness of the detection head, enabling the model to maintain stable detection performance in complex scenarios.
[0215] It should be noted that using group normalization (GN) instead of traditional batch normalization can alleviate the problem of unstable statistics during small-batch training and enhance the robustness of the model.
[0216] S5074: Based on the shared features after group normalization, output detection features for defect localization and classification through localization branch and classification branch respectively.
[0217] Among them, the localization branch and the classification branch are two parallel output paths in the detection head, respectively responsible for predicting the bounding box coordinates and the target category.
[0218] For example, the localization branch can output the coordinate information of the defect in the image, and the classification branch can output the specific type of the defect. Together, they provide core support for the final detection result.
[0219] Furthermore, the localization branch is responsible for predicting the bounding box coordinates of the defects, while the classification branch is responsible for predicting the category of the defects. The two branches work in parallel based on the processed shared features to jointly complete the detection task.
[0220] It should be noted that this design achieves decoupled prediction of defect location and attributes, enabling the model to more accurately complete the two core tasks.
[0221] Reference manual attached Figure 6 The diagram shows a schematic of a high-performance, lightweight detection head LSPD structure provided by an embodiment of the present invention.
[0222] Specifically, in Figure 6 In the diagram, P3, P4, and P5 represent input feature layers of different scales, corresponding to the feature information of small, medium, and large-sized defects, respectively, and are the input data of the detection head; Conv_GN1×1 represents a module integrating Conv2d, GroupNorm (GN), and SiLU activation layers, where Conv2d is a two-dimensional convolutional layer, GroupNorm is a group normalization layer, and SiLU is an activation function. This module is used to adjust feature channels and enhance feature representation; Conv_GN3×3 is the above integrated module with a convolutional kernel size of 3×3, used to extract local feature details; Conv_CLS is a classification branch convolutional layer responsible for outputting defect category information; Conv_Reg is a localization branch convolutional layer responsible for outputting defect location information; Scale is an adaptive scale adjustment layer used to adapt to defect features of different sizes.
[0223] Furthermore, Figure 6 The inclusion relationship is as follows: The lightweight detection head LSPD contains P3 / P4 / P5 input feature layers, multiple Conv_GN modules (1×1 and 3×3), Conv_CLS branch, Conv_Reg branch and Scale layer; each Conv_GN module contains Conv2d layer, GroupNorm layer and SiLU activation layer. Figure 6 The connection relationships clearly demonstrate the feature processing flow of the detection head: P3, P4, and P5 are respectively connected to the corresponding Conv_GN1×1 modules; the outputs of the three Conv_GN1×1 modules are connected to the Conv_GN3×3 module, and the output of the Conv_GN3×3 module is then connected to the next Conv_GN3×3 module; the output of the second Conv_GN3×3 module is connected to the Conv_CLS and Conv_Reg modules corresponding to P3, P4, and P5 respectively; and the Conv_Reg outputs corresponding to P3, P4, and P5 are also connected to their respective Scale layers.
[0224] It should be noted that, Figure 6 The lightweight inspection head shown compresses computational overhead through a shared convolution strategy, adapts to multi-scale defects through an adaptive scale layer, and enhances robustness through group normalization. While significantly reducing parameters and computational load, it effectively improves the detection accuracy of small defects in fabrics, making it suitable for the lightweight real-time inspection needs of industrial scenarios.
[0225] S508: Connect the input end, backbone network, neck network, and detection head sequentially according to the feature transmission path to complete the full architecture construction of the YOLO-RG detection model.
[0226] Among them, full architecture construction refers to integrating various functional modules according to a preset data flow.
[0227] Furthermore, the modules are connected along this path to achieve a closed loop from data input to feature output, ensuring the integrity and effectiveness of the model.
[0228] Furthermore, the components are connected in the order of data flow: "input end -> backbone network -> neck network -> detection head" to form a complete end-to-end detection model.
[0229] It should be noted that this step completes the assembly of the end-to-end detection model, enabling it to have full processing capabilities from image input to result output.
[0230] Reference manual attached Figure 7 The diagram shows a network schematic of the YOLO-RG algorithm for a multi-scale defect detection method for lightweight fabrics provided in an embodiment of the present invention.
[0231] Specifically, in Figure 7 In this model, YOLO-RG is a lightweight multi-scale defect detection model based on the improved YOLOv11n, comprising three core parts: Backbone, Neck, and Head. Convk=3s=2 represents a convolutional layer with kernel size k=3 and stride s=2, used for feature downsampling and basic feature extraction. C3k2 is the basic feature extraction module in the backbone network. C3k2_EMC is an improved lightweight multi-scale feature extraction module. SPPF is the spatial pyramid pooling module, used to fuse spatial feature information at different scales. C2PSA is the attention enhancement module, used to strengthen the expression of key defect features. RepMixCE is the feature fusion module that integrates gradient splitting and multi-scale aggregation. Concat is the feature concatenation module, used to integrate feature data from different branches. Upsample is the upsampling module, used to improve the resolution of feature maps. LSPD is the lightweight detection head, used to complete the task of defect localization and classification.
[0232] Furthermore, Figure 7 The inclusion relationship is as follows: YOLO-RG includes Backbone, Neck, and Head; Backbone includes modules such as convolutional layers and C3k2 / C3k2_EMC; Neck includes modules such as RepMixCE and Upsample; Head is the LSPD module. Figure 7 Connection relationship: The input is processed sequentially through convolutional layers, C3k2 and other modules in the Backbone. The outputs of different layers of the Backbone are connected to the RepMixCE and other modules of the Neck. After splicing and upsampling, the Neck output is connected to the LSPD of the Head.
[0233] It should be noted that, Figure 7 The YOLO-RG model shown here works in concert with lightweight feature extraction from the backbone network, efficient feature fusion from the neck network, and precise classification and localization from the detection head. This effectively improves the detection accuracy and robustness of multi-scale defects in fabrics while compressing the number of model parameters and computational load, making it suitable for the lightweight real-time detection needs of industrial scenarios.
[0234] In this embodiment of the invention, through the collaborative design of three core modules, the computational complexity and number of parameters are significantly reduced while the multi-scale feature extraction and fusion capabilities are enhanced, achieving a lightweight balance between accuracy and speed, and adapting to the computing power requirements of industrial deployment.
[0235] S6: Input the final training dataset into the YOLO-RG detection model to train the YOLO-RG detection model.
[0236] Model training refers to the process of inputting the final training dataset into the model and iteratively optimizing it to enable the model to learn defect features and classification and localization rules. Training evaluation metrics include model parameter count, AP, precision, FPS, recall, and mAP.
[0237] Specifically, the constructed expanded fabric dataset is used to train the built YOLO-RG detection model, enabling the model to learn the ability to identify defects from images.
[0238] In this embodiment of the invention, relying on the final training dataset containing diverse samples and combining multi-dimensional evaluation indicators, the model fully learns the feature differences of different defects, gradually optimizes parameters to improve classification accuracy and localization precision, and ensures that the model has stable detection performance.
[0239] S7: Obtain an image of the fabric to be detected.
[0240] The fabric image to be detected refers to the surface image of the fabric for which defect identification is required, and its format is consistent with that of the training dataset images.
[0241] Specifically, the image must meet preset size and color depth requirements to ensure it matches the input standards used during model training.
[0242] In this embodiment of the invention, by adapting the image format requirements of the training dataset, the compatibility between the input image and the model during training is ensured, providing a prerequisite for subsequent fast and accurate detection inference and meeting the real-time requirements of industrial automation detection.
[0243] S8: Input the image of the fabric to be detected into the trained YOLO-RG detection model and output the detection results.
[0244] The detection results refer to key information such as the type, quantity, and size of defects output by the model.
[0245] Specifically, the trained model can process the input fabric image and output detection results containing information such as the type and location of defects.
[0246] Specifically, the test results can clearly reflect the defects in the fabric, providing a direct basis for quality control.
[0247] Furthermore, compared with other common algorithm models, the proposed method effectively improves the problems of missing small defects and boundary positioning deviation, and can achieve accurate and compact positioning of defects of different sizes and shapes such as knots, broken yarns, and holes.
[0248] In this embodiment of the invention, thanks to the powerful multi-scale feature recognition capability of the trained model, the core information of defects can be output quickly and accurately. It performs particularly well in the detection of small defects such as holes and cotton knots, balancing detection accuracy and inference speed, and providing efficient and reliable technical support for quality control in the textile industry.
[0249] Reference manual attached Figure 8 The diagram shows a schematic of the structure of a lightweight fabric defect multi-scale detection system provided in an embodiment of the present invention.
[0250] This invention provides a lightweight fabric defect multi-scale detection system 20, including: a processor 201 and a memory 202;
[0251] 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 multi-scale detection method for defects in lightweight fabrics and achieve the same technical effect. To avoid repetition, the present invention will not elaborate further.
[0252] 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.
[0253] 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 are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DR RAM).
[0254] 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.
[0255] 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.
[0256] 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.
[0257] 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.
[0258] 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.
[0259] 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.
[0260] 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.
[0261] 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.
[0262] This invention provides a readable storage medium that stores a program or instructions on the storage medium. When the program or instructions are executed by a processor, they implement the steps of the above-described lightweight fabric defect multi-scale detection method and achieve the same technical effect. To avoid repetition, this invention will not elaborate further.
[0263] 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 multi-scale detection method for defects in lightweight fabrics, characterized in that, include: S1: Acquire fabric images, which include images of fabric defects and images of fabric without defects; S2: Preprocess the fabric image to obtain an initial dataset; S3: The DA-StyleGAN model is used to perform data augmentation on the preprocessed defect image to generate an enhanced defect image; S4: Merge the enhanced defect images with the initial dataset to form the final training dataset; S5: Construct the YOLO-RG detection model; The YOLO-RG detection model includes an input terminal, a backbone network, a neck network, and a detection head connected in sequence. The backbone network consists of multiple C3K2-EMC modules connected in sequence; the C3K2-EMC modules are constructed by stacking multiple Bottleneck_EMC basic units; the Bottleneck_EMC basic unit is based on the EMConv module as its core component; the EMConv module achieves multi-scale feature extraction by sequentially performing channel segmentation, tensor reshaping, multi-scale convolution extraction, and feature concatenation and fusion. The neck network consists of multiple RepMixCE modules connected in sequence. The RepMixCE modules are connected through a dual-path structure. The main path integrates a RepBlock sub-module using reparameterization technology. The features processed by the RepBlock sub-module are fused with the original shortcut path features through the dual-path structure. During the model training phase, the RepBlock sub-module is constructed as a structure containing multiple parallel convolutional branches. The lightweight detection head LSPD includes P3 / P4 / P5 input feature layers, multiple Conv_GN modules, a Conv_CLS branch, a Conv_Reg branch, and a scale layer. Each Conv_GN module contains a Conv2d layer, a GroupNorm layer, and a SiLU activation layer. P3, P4, and P5 are connected to their respective Conv_GN1×1 modules. The outputs of the three Conv_GN1×1 modules are connected to a Conv_GN3×3 module, and the output of this Conv_GN3×3 module is then connected to the next Conv_GN3×3 module. The output of the second Conv_GN3×3 module is connected to the Conv_CLS and Conv_Reg modules corresponding to P3, P4, and P5, respectively. The Conv_Reg outputs of P3, P4, and P5 are also connected to their respective scale layers. S6: Input the final training dataset into the YOLO-RG detection model to train the YOLO-RG detection model; S7: Acquire an image of the fabric to be detected; S8: Input the image of the fabric to be detected into the trained YOLO-RG detection model and output the detection result.
2. The method for multi-scale detection of defects in lightweight fabrics according to claim 1, characterized in that, S2 specifically includes: S201: Remove background clutter and edge interference from the fabric image through rotation correction operation; S202: Perform a selection operation on the rotated image to retain the region of interest containing defect features or effective fabric texture; S203: Using the Labelimg annotation tool, annotate the defects in the region of interest according to the YOLO data format to generate a label file containing defect type and location information; S204: Based on the preset image size and color depth, uniformly format the region of interest and the label file to construct the initial dataset.
3. The method for multi-scale detection of defects in lightweight fabrics according to claim 1, characterized in that, S3 specifically includes: S301: Design a defect-aware residual mask for the preprocessed defect image and generate mask information for controlling the synthesis; S302: Based on the mask information, the preprocessed defect image is augmented using the DA-StyleGAN model to generate an augmented defect image; S303: Based on the DA-StyleGAN model, a pixel-level mask image corresponding to the expanded defect image is generated synchronously to form an expanded defect image-pixel-level mask image data pair; S304: According to the preset verification process, the validity of the augmented defect image-pixel-level mask image data pair is verified using the YOLOv11n model, and the enhanced defect images that pass the verification are selected.
4. The method for multi-scale detection of defects in lightweight fabrics according to claim 1, characterized in that, The processing procedure of the EMConv module specifically includes: dividing the feature map input to the C3K2-EMC module into preset parts along the channel dimension through the channel segmentation operation: in, X This represents the input feature map of the EMConv module. C Represents the input feature map X Total number of channels This indicates a channel splitting operation. Indicates the division ratio. This indicates that the segmentation operation is performed along the channel dimension. This represents the branch feature map that retains the underlying basic features after segmentation. This represents a branch feature map used for multi-scale feature extraction; Through tensor reshaping, the segmented feature maps are divided into multiple groups along the channel dimension: in, R This indicates a tensor reshaping operation. This represents the reshaped target dimension. B Indicates batch size. G Indicates the number of groups. This represents the number of channels in each feature map group. H Indicates the height of the feature map. W Indicates the width of the feature map; Based on the grouped feature maps, perform multi-scale convolution extraction operations: in, This represents the convolution operation. Indicates a grouped index. Indicates the first The heterogeneous kernel size used by the group Indicates the first The output feature map after group convolution; Based on the extracted multi-scale features, a multi-scale fused feature map output by the EMConv module is generated through feature concatenation and fusion operations: in, This indicates a feature concatenation operation. This represents the multi-scale fused feature map that is the final output of the Group branch.
5. The method for multi-scale detection of defects in lightweight fabrics according to claim 1, characterized in that, The construction process of the RepBlock submodule specifically includes: The feature map input to the RepBlock submodule is then processed by multiple parallel convolutional branches. The feature maps of each of the parallel convolutional branches are processed through batch normalization: in, This represents the convolution operation. Indicates the input feature map, mean This represents the mean of the batch normalized layer statistics. This represents the standard deviation of the batch normalized stratum statistics. This represents the learnable scaling factor of the batch normalization layer. Indicates the offset factor of the batch normalization layer; During the model inference phase, multiple parallel convolutional branches and their corresponding batch normalization layers are merged into a single convolutional operation through reparameterization techniques. Based on the equivalent weights and equivalent biases, a single convolution operation is performed on the feature map to output the feature map processed by the RepBlock submodule.
6. The method for multi-scale detection of defects in lightweight fabrics according to claim 1, characterized in that, S5 specifically includes: S501: Construct the input terminal of the YOLO-RG detection model; S502: Based on the image data received at the input terminal, construct the backbone network of the YOLO-RG detection model; S503: Perform multi-scale feature extraction on the image data by configuring the C3K2-EMC module in the backbone network; S504: Based on the multi-scale features, construct the neck network of the YOLO-RG detection model; S505: By configuring the RepMixCE module in the neck network, feature fusion is performed on the gradient splitting and multi-scale fusion mechanism; S506: Based on the fusion features of the neck network after fusion, construct the detection head of the YOLO-RG detection model; S507: By configuring a lightweight detection head LSPD in the detection head, detection features for defect location and classification are output; S508: Connect the input terminal, backbone network, neck network, and detection head sequentially according to the feature transmission path to complete the construction of the YOLO-RG detection model.
7. The method for multi-scale detection of defects in lightweight fabrics according to claim 6, characterized in that, Specifically, S507 includes: S5071: Based on the fusion features of the neck network after fusion, the multi-branch detection heads are merged into a single shared convolutional branch through a shared convolution strategy; S5072: Based on the shared features output by the single shared convolutional branch, the feature scale is adjusted through an adaptive scale layer; S5073: Process the adjusted shared features through group normalization operation; S5074: Based on the shared features after group normalization, output detection features for defect localization and classification through localization branch and classification branch respectively.
8. A multi-scale defect detection system for lightweight fabrics, 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 lightweight fabric defect multi-scale detection method as described in any one of claims 1 to 7.
9. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the lightweight fabric defect multi-scale detection method as described in any one of claims 1 to 7.