An automatic defect identification system and method for woven carpet production
An improved automatic defect identification system for machine-woven carpet production utilizes feature extraction and fusion based on GhostNetV2 Bottleneck and BiFPN structures, combined with Focal-EIoU loss function and CycleGAN data augmentation. This system solves the problems of high recall for minute defects and high resolution for complex backgrounds in machine-woven carpet production, achieving lightweight real-time detection and fully automated quality control throughout the entire process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TIANJIN DIFENG TRADING CO LTD
- Filing Date
- 2026-04-28
- Publication Date
- 2026-07-10
AI Technical Summary
Existing technologies are insufficient to achieve high recall of minute defects, high resolution of complex backgrounds, rapid cross-material transfer capabilities, and lightweight real-time deployment in woven carpet production. This results in high missed detection rates and low quality inspection efficiency, failing to meet the real-time, full-inspection, and high-precision quality control requirements of modern high-speed production lines.
The GhostNetV2 Bottleneck module replaces the C2f module in the YOLOv8 architecture. It combines the BiFPN structure and the SimAM parameterless attention module for feature extraction and fusion, sets up a four-scale detection head, uses the Focal-EIoU loss function for training, and deploys it through an embedded AI computing platform. It also combines CycleGAN generative adversarial network for data augmentation, enabling rapid transfer and real-time detection of the lightweight model.
It enables precise location and classification of defects of various scales on the surface of machine-woven carpets, reduces the missed detection rate, improves the real-time performance and accuracy of detection, adapts to the production of carpets of different materials and patterns, and forms a fully automated quality control system.
Smart Images

Figure CN122368632A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine vision inspection technology in the textile industry, specifically to an automatic defect identification system and method for machine-woven carpet production. Background Technology
[0002] During the production of machine-woven carpets, various defects such as warp breaks, skipped yarns, oil stains, color differences, and uneven weft density are easily generated due to factors such as yarn tension fluctuations, wear of the carding mechanism, differences in yarn quality, and changes in environmental temperature and humidity. These defects severely affect the appearance quality and physical properties of the product. Traditional inspection methods mainly rely on manual visual inspection. However, due to the large width of the carpet, the high speed of movement, the small size of the defects, and the ease with which they can be confused with complex jacquard patterns, manual inspection has inherent drawbacks such as strong subjectivity, high missed detection rate due to visual fatigue, and low quality inspection efficiency. It is difficult to meet the real-time, full inspection, and high-precision quality control requirements of modern high-speed production lines. Some production lines have attempted to use machine vision methods based on traditional image processing, such as edge detection, texture segmentation, or grayscale thresholding to identify defects. However, the complex optical reflection caused by the pile structure of the carpet surface and the overlap of features between the pattern and the defect in the frequency and spatial domains make traditional methods less robust and unable to meet the online inspection requirements of carpets of different materials and patterns.
[0003] In recent years, deep learning-based object detection algorithms (such as YOLO, SSD, Faster R-CNN, etc.) have been gradually introduced into the field of fabric defect detection, achieving automatic identification of some defects through end-to-end feature learning. However, directly applying general detection models to woven carpet scenarios still faces multiple challenges: First, carpet defects vary greatly in scale, with the pixel area corresponding to a single broken warp usually less than one-tenth of the minimum detection scale of conventional models, leading to a large number of missed defects; Second, carpet background textures are complex and highly coupled with defect features, making it easy for models to misjudge normal changes in pile direction or pattern boundaries as defects; Third, in actual production, carpets of different materials and patterns are produced alternately, and existing model training relies on a large number of labeled samples, while defect samples are difficult to obtain and labeling costs are high, resulting in insufficient generalization ability of models across different materials; Fourth, industrial sites have strict requirements for real-time detection, while high-precision models often have high computational costs and are difficult to deploy on low-cost edge computing devices. Therefore, there is an urgent need for an automatic defect identification method and system for woven carpets that can simultaneously achieve high recall of minute defects, high resolution against complex backgrounds, rapid cross-material migration capability, and lightweight real-time deployment. Summary of the Invention
[0004] In order to solve the problems of the prior art, the present invention provides an automatic defect identification system and method for machine-woven carpet production.
[0005] To solve the above-mentioned technical problems, the present invention is achieved through the following technical solution: Firstly, a method for automatically identifying defects in the production of machine-woven carpets, comprising the following steps: Step S1: Image Acquisition and Preprocessing Industrial cameras deployed above the woven carpet production line are used to capture images of the carpet surface in real time. The images are then normalized to 640×640 pixels, and noise reduction and grayscale stretching are performed to obtain the input image. Step S2: Lightweight Feature Extraction The input image is fed into the backbone feature extraction network, which replaces the C2f module in the YOLOv8 architecture with the GhostNetV2 Bottleneck module to form the C2f_GhostNetV2 module, in order to extract multi-level feature maps. The specific structure of the C2f_GhostNetV2 module is as follows: the input feature map is divided into two parts by channels. The first part is directly connected to the output, and the second part passes through multiple GhostNet V2 Bottlenecks in sequence. Each GhostNet V2 Bottleneck contains: a first Ghost module, a decoupled fully connected attention branch, and a residual connection. The outputs of all Bottlenecks are concatenated with the first part in the channel dimension and then adjusted by a 1×1 convolution to adjust the number of channels. Step S3: Multi-scale feature fusion and attention enhancement The multi-level feature maps are input into the neck network, which uses a BiFPN structure for weighted bidirectional cross-scale connections and embeds a SimAM parameterless attention module after each cross-scale connection layer to generate a fused feature map. The energy function of the SimAM parameterless attention module is defined as follows: et=4(σ²+λ)(wt-μ)²+2σ²+2λ Where wt is the target feature point, μ and σ2 are the mean and variance of all feature points in the current feature map channel, respectively, and λ is the regularization coefficient; the attention weight for each feature point is the normalized value of 1 / σ2. Step S4: Setting up the four-scale detection head Four detection heads are set up, corresponding to feature map downsampling factors of 4x, 8x, 16x and 32x respectively; among them, the 4x downsampling feature map detection head is an added small target detection layer, used to detect extremely fine defects with an area of less than 16×16 pixels; the 8x, 16x and 32x detection heads are used for small and medium targets, medium and large targets and large targets respectively; Step S5: Defect classification, location and post-processing The fused feature map is input to the four detection heads, and each detection head outputs the defect category confidence score and bounding box coordinates. During inference, the candidate boxes are fused using weighted nonmaximum suppression (WeightedNMS) on the original detection results output by the four detection heads. After removing overlapping and redundant boxes, the final defect category, location, and confidence score information are output. During model training, the Focal-EIoU loss function is used to calculate the detection loss.
[0006] In one specific implementation of the first aspect, the Focal-EIoU loss function is calculated using the following formula: LFocal-EIoU=1-IoUγ·LEIoU Wherein, IoU is the intersection-union ratio of the predicted bounding box and the ground truth bounding box, γ is the focusing parameter, and γ takes a value of 0.5 to 2.0; LEIoU is the weighted sum of center point distance loss, width-height consistency loss and IoU loss.
[0007] In one specific implementation of the first aspect, the SimAM parameterless attention module calculates the energy function of each feature point and automatically generates three-dimensional attention weights based on the energy function values, without introducing additional learnable parameters; the energy function is defined as: et=4(σ²+λ)(wt-μ)²+2σ²+2λ Where wt is the target feature point, μ and σ2 are the mean and variance of all feature points in the current feature map channel, respectively, and λ is the regularization coefficient; the attention weight of each feature point is the normalized value of 1 / σ2.
[0008] In one specific implementation of the first aspect, the feature map downsampling factors corresponding to the four detection heads are 4x, 8x, 16x and 32x respectively; the 4x downsampling feature map detection head is an added small target detection layer used to detect defects with an area smaller than 16×16 pixels; In step S1, the image is normalized to 640×640 pixels, and the frame rate of the industrial camera is synchronized with the carpet travel speed, so that the overlap rate of two adjacent frames is not less than 20%.
[0009] Secondly, an automatic defect identification system for machine-woven carpet production, used to implement an automatic defect identification method for machine-woven carpet production, including: Image acquisition module: includes at least one industrial camera and light source, used to acquire images of the carpet surface in real time and transmit them to the image preprocessing unit; Image preprocessing unit: used to normalize the original image to 640×640 pixels and perform noise reduction and grayscale stretching; Lightweight feature extraction module: Deployed on an embedded AI computing platform, with an embedded C2f_GhostNetV2 backbone network, used to extract multi-scale feature maps from input images; Feature fusion and enhancement module: Includes a neck network with a BiFPN structure and a SimAM parameterless attention module, used to generate enhanced fused feature maps; Multi-scale detection module: contains four detection heads, corresponding to 4x, 8x, 16x and 32x downsampling feature maps respectively, and outputs defect category, coordinates and confidence level; Post-processing module: used to perform weighted nonmaximum suppression and output the final detection result; Defect output and marking module: used to associate the detection results with the spatial location of the carpet and drive the marking device or output an alarm signal.
[0010] In one specific implementation of the second aspect, the embedded AI computing platform uses an NVIDIA Jetson Orin or Rockchip RK3588 chip, and the input image resolution is fixed at 640×640; the C2f_GhostNetV2 backbone network is deployed with INT8 precision after quantization perception training, and the measured detection frame rate on the platform is not less than 30 frames / second.
[0011] Thirdly, a model training method for an automatic defect identification method in machine-woven carpet production includes the following steps: Step T1: Collect and label a dataset of carpet defect images. The defect types include at least five categories: broken warp, skipped yarn, oil stains, color difference, and uneven weft density. Extract the defect areas from the source carpet images as masks, use CycleGAN generative adversarial network to perform style transfer on the non-defect background areas, and use Poisson fusion to generate synthetic samples with the transferred background and the retained defect areas. Step T2: Divide the dataset and synthetic samples into a training set, a validation set, and a test set; Step T3: Construct the initial detection network, the backbone of which is C2f_GhostNetV2, the neck is BiFPN+SimAM, and the detection head is a four-scale detection head; Step T4: The detection network is trained end-to-end using the Focal-EIoU loss function and the AdamW optimizer, with an initial learning rate of 0.001 and a cosine annealing strategy for decay. Step T5: After training is complete, perform channel pruning and quantization-aware training on the model to generate a lightweight deployment model with INT8 quantization.
[0012] In one specific implementation of the third aspect, the discriminator of the CycleGAN generative adversarial network adopts a multi-scale gradient penalty mechanism to ensure that the texture features of the generated samples are consistent with the original carpet material; when training with the generated samples, only the features of the defective regions are weighted, and the loss weight of the background regions is reduced by 50%.
[0013] In one specific implementation of the first aspect, a dynamic model distillation step is also included: Multiple detection models with different accuracy-speed are pre-trained, including lightweight models, standard models, and high-precision models; During the production process, images of the current carpet pattern are collected, input into an LSTM network to predict the carpet type, and the corresponding detection model is automatically loaded based on the prediction results. When a complex jacquard pattern is detected, switch to the high-precision model; when a single background color or a simple pattern is detected, switch to the lightweight model.
[0014] In one specific implementation of the second aspect, a closed-loop control interface is also included: the defect output and marking module sends the defect location coordinates to the inkjet marking device, and at the same time feeds back the yarn breakage defect signal to the carpet loom control system in real time, triggering the yarn breakage automatic stop and tension coordinated adjustment.
[0015] The beneficial effects of this invention are as follows: 1. By constructing a detection model based on a lightweight C2f_GhostNetV2 backbone network, redundant feature maps are generated using the inexpensive linear transformation of the Ghost module and combined with a decoupled fully connected attention mechanism, significantly reducing the number of model parameters and computational redundancy while maintaining high representational capability. Furthermore, BiFPN weighted bidirectional cross-scale connectivity and a SimAM parameterless attention module are introduced into the neck network. Three-dimensional attention weights are automatically generated through a channel-wise energy function, enhancing the effective information representation of the feature maps without requiring additional learnable parameters. Combined with a four-scale detection head (including a high-resolution detection layer for extremely fine defects) and weighted non-maximum suppression post-processing, accurate localization and classification of various scale defects on carpet surfaces, such as broken warp threads and skipped yarns (especially minor defects as small as a single broken yarn), are achieved. Based on this, the Focal-EIoU loss function is used for training. The gradient contribution of easy and difficult samples is adaptively adjusted through the focus parameter. Combined with the joint constraints of the distance between the center points of the bounding boxes, the consistency of width and height, and the intersection-over-union ratio, the problem of sparse carpet defect samples and inaccurate regression of long strip defects is effectively alleviated. The above improvements work together to enable the model to achieve high recall and high precision detection without the need for high-computing hardware, and it has good anti-interference ability against complex carpet texture backgrounds.
[0016] 2. This invention features systematic optimization in engineering deployment. A lightweight model with INT8 accuracy is generated through quantized perception training and channel pruning, capable of running on embedded edge computing platforms to achieve real-time online detection matching the carpet's travel speed. An LSTM network dynamically identifies the complexity of the current carpet pattern, adaptively loading pre-trained models of different accuracy-speed (lightweight, standard, or high-precision models). While ensuring real-time detection, it automatically switches to the high-precision model for complex jacquard patterns, achieving a dynamic balance between efficiency and accuracy. Furthermore, CycleGAN generative adversarial networks and Poisson fusion technology are used to transfer defect features from carpets of known materials to synthetic backgrounds of other materials. Combined with a background region loss reduction training strategy, this effectively solves the problems of difficult sample collection, high annotation costs, and weak cross-material generalization ability for various carpet defects in actual production. Ultimately, by linking the detection results with the inkjet marking device and the loom control system, online marking of defects, audible and visual alarms, automatic stop of yarn breakage, and closed-loop tension adjustment were achieved, forming a fully automated quality control system from image acquisition and intelligent recognition to execution feedback, which significantly improved the intelligence level and product yield of the carpet production line. Attached Figure Description
[0017] Figure 1 This is a schematic diagram of the overall system architecture of the present invention.
[0018] Figure 2 This is a schematic diagram of the detection network structure of the present invention.
[0019] Figure 3 This is a schematic diagram of the online detection process and closed-loop control process of the present invention. Detailed Implementation
[0020] The technical solutions of the present invention will be clearly and completely described below with reference to the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0021] like Figures 1 to 3 The present invention relates to an automatic defect identification system and method for machine-woven carpet production.
[0022] 1. Overall System Architecture The automatic identification system provided by this invention is deployed above a machine-woven carpet production line and mainly includes: an image acquisition module, an image preprocessing unit, an embedded AI computing platform (for deploying the detection model), a defect output and marking module, and an optional closed-loop control interface. The carpet travels at a linear speed of 0.5 m / s to 2.0 m / s, and the industrial camera is fixed at the inspection station on the production line. The light source uses an LED ring shadowless lamp to ensure uniform illumination.
[0023] 2 Image Acquisition and Preprocessing 2.1 Hardware Parameters A global shutter industrial camera with a resolution of at least 5 megapixels (such as the Basler acA2440-35uc) is used, with a lens focal length of 8–12 mm and a working distance of 300–500 mm, to ensure that the field of view covers the width of the carpet (usually 2–4 m requires multiple cameras stitched together; this example uses a single camera). The camera frame rate is set to 20–40 fps, synchronized with the carpet travel speed via an encoder. The overlap rate between adjacent frames is controlled between 15% and 25% (meeting the requirement of "not less than 20%" in claim 11; in actual implementation, a target overlap rate of 22% can be set) to avoid missed detections.
[0024] 2.2 Preprocessing Steps Normalization: Crop and scale the original image (e.g., 2448×2048 pixels) to a fixed size of 640×640 pixels (maintaining aspect ratio, padding any insufficient parts with 0).
[0025] Noise reduction: Fast median filtering (window size 3×3) is used to remove salt and pepper noise.
[0026] Grayscale stretching: Adaptive histogram equalization (CLAHE, limit contrast to 2.0, grid 8×8) is used to address the contrast reduction on the carpet surface caused by uneven lighting.
[0027] Input / output: Original RGB image, converted to a 640×640×3 tensor, with pixel values normalized to [0,1].
[0028] 3. Detect network structure This invention improves upon the YOLOv8 architecture in three aspects: a lightweight backbone, multi-scale feature fusion and attention enhancement, and a four-scale detection head. The overall network structure is as follows: Figure 1 As shown.
[0029] 3.1 Backbone Network: C2f_GhostNetV2 The backbone network receives a 640×640×3 input, which is downsampled by initial convolution (stride 2) and then sequentially passed through multiple C2f_GhostNetV2 modules. The structure of each C2f_GhostNetV2 module is as follows: Channel segmentation: dividing the input feature map Divided along the channel dimension ,in occupy .
[0030] Bottleneck handling: Passing through in sequence There are 1 GhostNet V2 Bottleneck (n is set to 2, 4, or 6 depending on the module location). Each GhostNet V2 Bottleneck: Ghost module: First, compress the input channels using a regular convolution (1×1). Then, features are extracted using depthwise convolution (3×3), and then generated using inexpensive linear transformations (e.g., 3×3 depthwise convolution or 5×5 depthwise convolution). The number of redundant feature maps results in a final output channel count of [number]. .
[0031] Decoupling the fully connected attention branch: Perform global average pooling on the input feature map to obtain... The vector is passed through a fully connected layer (without bias) to generate channel attention weights, which are then activated with a sigmoid function and multiplied by the output of the Ghost module.
[0032] Residual connection: Add a residual connection if the number of input and output channels is the same.
[0033] splicing and output: Concatenate the outputs of all Bottlenecks along the channel dimension to obtain Then, the number of channels is adjusted to the predetermined value through a 1×1 convolution.
[0034] The backbone network outputs four feature maps at different scales, which are downsampled by 4x (160×160), 8x (80×80), 16x (40×40), and 32x (20×20) relative to the input image, respectively. These feature maps serve as the input to the neck network.
[0035] 3.3.2 Neck Network: BiFPN + SimAM The neck network employs a weighted bidirectional feature pyramid (BiFPN) structure to achieve multi-scale feature fusion from top to bottom and bottom to top. A SimAM parameterless attention module is embedded after each cross-scale connection layer.
[0036] SimAM attention implementation method: For a given feature map Calculate each spatial location and each channel Energy function on The specific energy function adopts a modified parameterless form: in For position eigenvalues at that location and These are the channels where the feature point is located. The mean and variance of all spatial locations (i.e., for all spatial locations) (pixel statistics) Regularization coefficient (range of values) Preferred ).
[0037] Attention weights for each feature point In practice, the feature map is directly multiplied by the weight matrix. No training parameters are required.
[0038] The neck network ultimately outputs four fused feature maps, with resolutions corresponding one-to-one with the four scales output by the backbone. .
[0039] 3.3 Detection Head: Four-Scale Independent Detection Four parallel detection heads are set up, each corresponding to a feature map of one scale: Detection head P4: corresponds to a 4x downsampled feature map (160×160), specifically designed for detecting extremely fine defects (such as single broken wires or tiny oil stains) with an area smaller than 16×16 pixels.
[0040] Detection head P8: corresponds to 8x downsampling (80×80), detects small and medium targets (16~64 pixels).
[0041] Detection head P16: corresponds to 16x downsampling (40×40), for detecting medium to large targets (64~128 pixels).
[0042] Detection head P32: corresponds to 32x downsampling (20×20), detects large targets (>128 pixels) and global texture anomalies.
[0043] Each detection head includes: Two 3×3 convolutional layers, with 256 channels; A classification branch (output) (probabilities of each category); One regression branch (outputs 4 bounding box offsets + 1 target confidence).
[0044] Post-inference processing: The original bounding boxes (with confidence scores) output by the four detectors are fused using weighted non-maximum suppression (NMS). The IoU threshold is set to 0.5, and the confidence threshold is 0.3. For overlapping boxes, their coordinates are weighted and averaged, with the weight being the confidence score of the detection box minus the corrected coordinates. The same applies to width and height.
[0045] 4. Loss Function The total loss function during the training phase is: in Binary cross-entropy loss is used (independent for each class). For distribution focus loss. For bounding box regression loss. Using Focal-EIoU: In the formula: The intersection-union ratio (IU) between the predicted bounding boxes and the ground truth bounding boxes: The focusing parameter has a value range of 0.5 to 2.0, with 1.0 being preferred. Where ρ is the Euclidean distance. The minimum diagonal length of the bounding box that covers both frames. This represents the width and height of the bounding box.
[0046] This loss function addresses the sample imbalance problem and provides more accurate gradients for defects with large aspect ratio differences (such as skipped yarn).
[0047] Additional notes: The loss function mentioned above is only used for parameter updates during the model training phase; during the inference phase (online detection), the model only performs forward propagation, does not calculate the loss function, and directly outputs the detection results, which are then post-processed using weighted NMS.
[0048] 5. Model Training Methods 5.1 Dataset Construction Collect images of several types of carpets (different materials, patterns, and colors) from the actual production line. Mark five main defects: broken warp, skipped yarn, oil stains, color difference, and uneven weft density. The marking boxes should be axis-aligned rectangles.
[0049] Due to the scarcity of actual defect samples, a CycleGAN + Poisson fusion method was used for data augmentation. Extract the defective areas from the source carpet image into a binary mask.
[0050] The CycleGAN model is trained to transfer the background texture of the source carpet onto the background of the target carpet (which is flawless). The CycleGAN discriminator uses Multi-Scale Gradient Penalty (MSGP) as the loss weight. .
[0051] After generating the transferred background image, the original defect region (preserving its shape and color) is inserted into the same position in the transferred background using Poisson fusion to obtain the synthetic sample. During fusion, the gradient field of the defect region is preserved, while the background gradient comes from the transferred background, ensuring smooth boundaries.
[0052] When training the model using the synthetic samples, to suppress overfitting of the model to the background texture, the loss weight for the background region is reduced by 50%. Specifically, when calculating the total loss, the feature map is divided into defect regions and background regions based on the mask generated by the bounding boxes. The loss term for the background region is multiplied by a coefficient of 0.5, while the loss term for the defect region remains unchanged. This strategy forces the model to learn more about the shape, color, and texture features of the defects themselves, rather than the background differences between different carpet materials, thereby improving the model's generalization ability across patterns.
[0053] The final dataset contains real and synthetic samples in a 1:1 ratio, totaling no less than 10,000 images, which are divided into training, validation, and test sets in an 8:1:1 ratio.
[0054] 5.2 Training Hyperparameters Optimizer: AdamW, initial learning rate Weight decay .
[0055] Learning rate scheduling: cosine annealing, T_max = 300 rounds, minimum learning rate .
[0056] Batch size: 16 (adjusted according to GPU memory).
[0057] Input dimensions: 640×640.
[0058] Data augmentation: random horizontal flip (probability 0.5), random scaling (0.8~1.2), HSV hue fine-tuning (hue=0.015, saturation=0.7, value=0.4).
[0059] Training rounds: 300 rounds, early stop patience = 50 rounds.
[0060] 5.3 Model Quantization and Deployment After training, channel pruning was performed (removing redundant convolutional kernels, pruning rate 30%). Then, Quantization-Aware Training (QAT) was employed: pseudo-quantized nodes were inserted into the training network to simulate activation and weight distribution at INT8 precision, fine-tuned for 20 epochs. Finally, the TensorRT engine (FP16 or INT8) was exported. The deployment platform was an NVIDIA Jetson Orin NX 16GB, with an input resolution of 640×640. The measured inference speed of the INT8 model reached 45 fps (meeting the requirement of "not less than 30 frames / second" in claim 6).
[0061] 6. Dynamic model switching (optional) To accommodate different carpet complexities, three models were pre-trained: Lightweight model: backbone is C2f_GhostNetV2 (channel reduction factor 0.5), detector head has 128 channels, inference frame rate >80 fps.
[0062] Standard model: As mentioned above, frame rate ~45 fps.
[0063] High-precision model: The backbone is replaced with C2f_DCN (deformable convolution), the detection head has 512 channels, and the frame rate is ~20 fps.
[0064] During production, every 100 frames of images received are used, and the last 10 frames are input into the LSTM network. The LSTM network structure is as follows: the input is a 224×224 grayscale image, which is flattened by a convolutional layer (16 3×3 convolutional kernels) and then fed into a single-layer LSTM (128 hidden units). The output is a pattern complexity score (0~1). A lightweight model is used for thresholds below 0.3, a standard model for 0.3~0.7, and a high-precision model for above 0.7. Frame continuity is maintained during switching, and a new model is loaded starting from the next frame.
[0065] 7. Online detection and closed-loop control Testing process: The camera captures carpet images in real time and triggers preprocessing simultaneously.
[0066] The preprocessed 640×640 image is fed into the deployed detection model.
[0067] The model outputs the estimated defect category, bounding box, and confidence level. If the confidence level is ≥0.5, it is judged as a defect.
[0068] The defect location is converted into actual physical coordinates (by combining camera calibration parameters with carpet encoder readings).
[0069] Trigger the inkjet marking device (response delay <50 ms) to mark the defect area on the back of the carpet, and simultaneously trigger an audible and visual alarm.
[0070] If the defect type "broken warp" accumulates to more than 3 times / meter, a "pause request" is sent to the carpet loom PLC via serial port or Ethernet. The loom will then automatically stop due to broken yarn and adjust the yarn tension (increasing it by 2% to 5%, which is sent to the loom frequency converter via analog output or Modbus protocol).
[0071] Example Example 1: Testing of a polypropylene loop pile carpet production line Production conditions: The carpet is 2.5 m wide and the walking speed is 1.2 m / s; The existing combing mechanism on the production line is prone to warp breakage and yarn skipping; Ambient lighting: Workshop fluorescent lights, with the addition of LED ring lights (color temperature 5000K, illuminance 1000 lux).
[0072] System Configuration: It uses four industrial cameras arranged side by side (each covering a 0.65 m field of view), each equipped with an 8 mm lens, a working distance of 450 mm, a resolution of 2448×2048, and a frame rate of 30 fps.
[0073] Each camera is connected to a Jetson Orin NX edge computer (4 in total), each processing its own field of view. The central server aggregates the data.
[0074] The deployed standard model (C2f_GhostNetV2 + BiFPN + SimAM + 4 heads) achieved a single-card inference speed of 42 fps after quantization, meeting the 30 fps real-time requirement.
[0075] Training data: A total of 3,000 images of polypropylene loop pile carpets from the production line were collected (including 156 real defect annotations). An additional 3,000 composite images were generated using CycleGAN, and the training was performed with the background loss reduced by 50% according to the method described in Section 3.5.1. Defect distribution: warp breakage 38%, skipped yarn 25%, oil stains 20%, color difference 10%, uneven weft density 7%.
[0076] Test results: In actual production, it ran continuously for 72 hours, processing approximately 3.11 million images. Evaluation metrics: The overall average accuracy mAP@0.5 is 94.6%, which is 5.3 percentage points higher than the baseline YOLOv8m, and the inference speed is 2.1 times faster (after quantization).
[0077] False positive analysis: A small number of normal carpet shadows or changes in pile direction were misjudged as "skipped yarn". After a second adjustment by adding negative samples (normal images), the false detection rate was reduced to below 2.1%.
[0078] Economic benefits: Replacing the original 3 quality inspection stations saves approximately 300,000 yuan in labor costs annually; the defect rate caused by missed defects has decreased from 4.7% to 1.2%.
[0079] The technical solution provided by this invention can be directly embedded into existing carpet weaving production lines without significant hardware modifications. The algorithm is lightweight and can run on edge computing devices, with high recognition accuracy and strong real-time performance, and has good industrial promotion value.
[0080] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for automatically identifying defects in machine-woven carpet production, characterized in that, Includes the following steps: Step S1: Image Acquisition and Preprocessing Industrial cameras deployed above the woven carpet production line are used to capture images of the carpet surface in real time. The images are then normalized to 640×640 pixels, and noise reduction and grayscale stretching are performed to obtain the input image. Step S2: Lightweight Feature Extraction The input image is fed into the backbone feature extraction network, which replaces the C2f module in the YOLOv8 architecture with the GhostNet V2Bottleneck module to form the C2f_GhostNetV2 module, in order to extract multi-level feature maps. The specific structure of the C2f_GhostNetV2 module is as follows: the input feature map is divided into two parts by channels. The first part is directly connected to the output, and the second part passes through multiple GhostNet V2 Bottlenecks in sequence. Each GhostNet V2 Bottleneck contains: a first Ghost module, a decoupled fully connected attention branch, and a residual connection. The outputs of all Bottlenecks are concatenated with the first part in the channel dimension and then adjusted by a 1×1 convolution to adjust the number of channels. Step S3: Multi-scale feature fusion and attention enhancement The multi-level feature maps are input into the neck network, which uses a BiFPN structure for weighted bidirectional cross-scale connections and embeds a SimAM parameterless attention module after each cross-scale connection layer to generate a fused feature map. The energy function of the SimAM parameterless attention module is defined as follows: in, For the target feature point, and These are the mean and variance of all feature points within the current feature map channel, respectively. Here is the regularization coefficient; the attention weight for each feature point is... normalized value Step S4: Setting up the four-scale detection head Four detection heads are set up, corresponding to feature map downsampling factors of 4x, 8x, 16x and 32x respectively; among them, the 4x downsampling feature map detection head is an added small target detection layer, used to detect extremely fine defects with an area of less than 16×16 pixels; the 8x, 16x and 32x detection heads are used for small and medium targets, medium and large targets and large targets respectively; Step S5: Defect classification, location and post-processing The fused feature map is input to the four detection heads, and each detection head outputs the defect category confidence score and bounding box coordinates. During inference, the candidate boxes are fused using weighted nonmaximum suppression (Weighted NMS) on the original detection results output by the four detection heads. After removing overlapping and redundant boxes, the final defect category, location, and confidence score information are output. During model training, the Focal-EIoU loss function is used to calculate the detection loss.
2. The method according to claim 1, characterized in that: The formula for calculating the Focal-EIoU loss function is as follows: in, The intersection-union ratio (IU) of the predicted bounding box and the ground truth bounding box. To focus parameters, The value ranges from 0.5 to 2.0; For center point distance loss, width and height consistency loss and The weighted sum of losses.
3. The method according to claim 1, characterized in that: The SimAM parameterless attention module calculates the energy function of each feature point and automatically generates 3D attention weights based on the energy function values, without introducing additional learnable parameters; the energy function is defined as: in, For the target feature point, and These are the mean and variance of all feature points within the current feature map channel, respectively. Here is the regularization coefficient; the attention weight for each feature point is... The normalized value.
4. The method according to claim 1, characterized in that: The feature map downsampling factors corresponding to the four detection heads are 4x, 8x, 16x and 32x respectively; the 4x downsampling feature map detection head is an added small target detection layer used to detect defects with an area smaller than 16×16 pixels; In step S1, the image is normalized to 640×640 pixels, and the frame rate of the industrial camera is synchronized with the carpet travel speed, so that the overlap rate of two adjacent frames is not less than 20%.
5. An automatic defect identification system for machine-woven carpet production, used to implement the method described in any one of claims 1 to 4, characterized in that, include: Image acquisition module: includes at least one industrial camera and light source, used to acquire images of the carpet surface in real time and transmit them to the image preprocessing unit; Image preprocessing unit: used to normalize the original image to 640×640 pixels and perform noise reduction and grayscale stretching; Lightweight feature extraction module: Deployed on an embedded AI computing platform, with an embedded C2f_GhostNetV2 backbone network, used to extract multi-scale feature maps from input images; Feature fusion and enhancement module: Includes a neck network with a BiFPN structure and a SimAM parameterless attention module, used to generate enhanced fused feature maps; Multi-scale detection module: contains four detection heads, corresponding to 4x, 8x, 16x and 32x downsampling feature maps respectively, and outputs defect category, coordinates and confidence level; Post-processing module: used to perform weighted nonmaximum suppression and output the final detection result; Defect output and marking module: used to associate the detection results with the spatial location of the carpet and drive the marking device or output an alarm signal.
6. The system according to claim 1, characterized in that: The embedded AI computing platform uses NVIDIA Jetson Orin or Rockchip RK3588 chips, and the input image resolution is fixed at 640×640. The C2f_GhostNetV2 backbone network is deployed with INT8 precision after quantization perception training, and the measured detection frame rate on the platform is no less than 30 frames / second.
7. A model training method for the method of claim 1, characterized in that, Includes the following steps: Step T1: Collect and label a dataset of carpet defect images. The defect types include at least five categories: broken warp, skipped yarn, oil stains, color difference, and uneven weft density. Extract the defect areas from the source carpet images as masks, use CycleGAN generative adversarial network to perform style transfer on the non-defect background areas, and use Poisson fusion to generate synthetic samples with the transferred background and the retained defect areas. Step T2: Divide the dataset and synthetic samples into a training set, a validation set, and a test set; Step T3: Construct the initial detection network, the backbone of which is C2f_GhostNetV2, the neck is BiFPN+SimAM, and the detection head is a four-scale detection head; Step T4: The detection network is trained end-to-end using the Focal-EIoU loss function and the AdamW optimizer, with an initial learning rate of 0.001 and a cosine annealing strategy for decay. Step T5: After training is complete, perform channel pruning and quantization-aware training on the model to generate a lightweight deployment model with INT8 quantization.
8. The model training method according to claim 7, characterized in that, The discriminator of the CycleGAN generative adversarial network adopts a multi-scale gradient penalty mechanism to ensure that the texture features of the generated samples are consistent with the original carpet material. When training with the generated samples, only the features of the defect area are weighted, and the loss weight of the background area is reduced by 50%.
9. The method for automatically identifying defects in machine-woven carpet production according to claim 1, characterized in that, It also includes a dynamic model distillation step: Multiple detection models with different accuracy-speed are pre-trained, including lightweight models, standard models, and high-precision models; During the production process, images of the current carpet pattern are collected, input into an LSTM network to predict the carpet type, and the corresponding detection model is automatically loaded based on the prediction results. When a complex jacquard pattern is detected, switch to the high-precision model; when a single background color or a simple pattern is detected, switch to the lightweight model.
10. The automatic defect identification system for machine-woven carpet production according to claim 5, characterized in that, It also includes a closed-loop control interface: the defect output and marking module sends the defect location coordinates to the inkjet marking device, and at the same time feeds back the yarn breakage defect signal to the carpet loom control system in real time, triggering the yarn breakage automatic stop and tension coordinated adjustment.