Cloth defect detection method, system and device based on RT-DETR model and medium

By improving the RT-DETR model, enhancing weak feature contrast, filtering texture noise, and optimizing defect localization, the problems of accuracy, efficiency, and anti-interference in the detection of defects in knitted fabrics were solved, achieving efficient and accurate defect detection.

CN122243981APending Publication Date: 2026-06-19SHANGHAI STRATOSPHERE INFORMATION TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANGHAI STRATOSPHERE INFORMATION TECH CO LTD
Filing Date
2026-03-25
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing technologies suffer from poor generalization ability, severe texture noise interference, high false detection rate, and slow detection speed in the detection of defects in knitted fabrics, making it difficult to achieve a balance between high accuracy and high efficiency.

Method used

The RT-DETR model is adopted, and the weak feature contrast is enhanced by IEL, texture noise is filtered by ASSA, and defect localization is optimized by NWD-GIoU hybrid loss function. The hybrid loss function is constructed to optimize the bounding box coordinates, so as to achieve end-to-end detection.

Benefits of technology

It improves detection accuracy, anti-interference ability and real-time performance. The model mAP@0.5 reaches 0.762, the false detection rate is controlled within 5%, and the detection speed reaches 63.4 frames/s, which is suitable for knitted fabric production lines.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122243981A_ABST
    Figure CN122243981A_ABST
Patent Text Reader

Abstract

The method of this invention includes: acquiring sample knitted fabric images, constructing a knitted fabric image dataset, the knitted fabric image dataset containing at least sample knitted fabric images, defect types, and defect regions; based on the knitted fabric image dataset, selecting feature sequences for training a fabric defect detection model, the feature sequences being obtained by enhancing the texture differences of defect regions in the images to extract multi-scale features using a ResNet18 network as the backbone network, and using a self-attention sparsity mechanism to filter the multi-scale features; using uncertainty minimization scoring to filter defects from the feature sequences, and constructing a hybrid loss function to optimize the bounding box coordinates of the defects; training a fabric defect detection model based on the RT-DETR model on the knitted fabric image dataset based on the feature sequences and the optimized bounding box coordinates; inputting the knitted fabric image to be detected into the trained fabric defect detection model and outputting the result. This invention improves the performance of knitted fabric defect detection based on an improved RT-DETR architecture.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of machine vision inspection technology in the textile industry, specifically relating to a method and system for detecting defects in knitted fabrics based on an improved real-time end-to-end inspection Transformer (RT-DETR). It is particularly suitable for the automatic detection of typical defects in knitted fabrics such as broken yarns, broken wefts, stains, holes, and scratches. It can replace traditional manual visual inspection and realize efficient and standardized quality inspection in the large-scale production of knitted fabrics. In particular, it is a method, system, device, and medium for detecting fabric defects based on the RT-DETR model. Background Technology

[0002] Existing technologies and corresponding patents related to fabric defect detection mainly fall into the following categories: Patent CN112488986A (Method, Device, and System for Fabric Surface Defect Recognition Based on YOLO Convolutional Neural Network): This patent uses OpenCV to preprocess fabric images, performing operations such as threshold binarization, edge detection, illumination equalization, and median filtering. The dataset is then expanded by randomly adjusting the Gamma curve, and finally, a YOLOv3 neural network model is trained to achieve defect recognition. This method relies heavily on traditional OpenCV algorithms for preprocessing, resulting in poor generalization ability. Furthermore, the YOLOv3 model has limited ability to capture weak-feature defects in knitted fabrics, failing to achieve end-to-end detection.

[0003] Patent CN119223998A (A Method and System for Defect Detection of Knitted Fabrics Based on Projection Method): This patent first acquires and preprocesses images of knitted fabrics. For non-jacquard fabrics, it directly detects defects. For jacquard fabrics, it uses Gabor filtering to separate texture feature regions and then performs diffusion processing. Next, it identifies potential defect areas through multi-directional projection. Finally, it uses the YOLOv7 model to detect defects and combines this with the fabric's multi-dimensional characteristics to generate a quality assessment result. This method employs a multi-stage detection mode of "projection method + YOLOv7," relies on manual parameter adjustment, and is susceptible to noise interference from knitted fabric textures. It also lacks sufficient accuracy in locating defects with special shapes such as thin, broken yarns.

[0004] Patent CN117974673A (A method, system, and storage medium for detecting defects in patterned fabrics): This patent adds a BRA attention module after the SPPF layer of the backbone network in the YOLOv8s model, and adds a 160×160 feature output layer in the neck network for detecting small target defects, using a BIFPN structure as the feature fusion network. Although this method improves for small target detection, it still uses the traditional anchor box mechanism, which has limitations in end-to-end detection.

[0005] Traditional OpenCV algorithms have poor generalization ability and low detection rate of weak feature defects: Existing technologies such as CN112488986A rely on traditional OpenCV algorithms such as threshold binarization and edge detection for preprocessing. These algorithms have poor adaptability to changes in lighting and fabric batch differences, and have weak generalization ability. At the same time, they have a low detection rate for low-contrast weak feature defects such as broken yarns and small holes in knitted fabrics, making it difficult to effectively capture the feature information of such defects and easily resulting in missed detections.

[0006] The problem of feature dilution caused by texture noise in knitted fabrics is prominent: Existing technologies such as CN119223998A use the projection method to identify defect areas. When processing the periodic texture of knitted fabrics, texture noise is easily confused with defect features, resulting in feature dilution. Although CN117974673A adds an attention module, it is not specifically optimized for the texture characteristics of knitted fabrics and cannot effectively focus on defect areas. Both types of methods have high false detection rates, and the problem is more significant in high-density knitted fabric detection scenarios.

[0007] Large deviations in locating special types of defects: Existing technologies such as CN117974673A use a traditional anchor frame mechanism, which has poor adaptability to irregularly shaped defects such as small holes and thin, long broken yarns, and has low bounding box regression accuracy; CN119223998A's projection method is prone to displacement in locating defects such as thin, long broken yarns, and it is difficult to accurately fit the actual shape of the defect, which cannot meet the requirements of high-precision detection.

[0008] Imbalance between model accuracy and efficiency: Existing technologies such as CN119223998A adopt a multi-stage mode of "projection method preprocessing + YOLOv7 detection", which is cumbersome and has a cumulative amount of calculation, resulting in slow detection speed and failing to meet the detection requirements of hundreds of meters per minute on high-speed production lines; Although CN117974673A optimizes the detection of small targets, the number of parameters in the improved model has not been reduced, sacrificing some real-time performance while ensuring detection accuracy, making it difficult to achieve a balance between accuracy and efficiency.

[0009] Reliance on NMS post-processing, multi-stage optimization, and manual parameter adjustment: Existing technologies such as CN117974673A require NMS post-processing to remove duplicate detection boxes, which increases system complexity; CN119223998A requires manual adjustment of projection method parameters and Gabor filter parameters, and adopts a multi-stage detection process, which is cumbersome; neither of these methods maintains the advantages of end-to-end detection, has poor generalization ability, and is difficult to adapt to different types of knitted fabric detection scenarios. Summary of the Invention

[0010] To address the aforementioned technical problems, this invention provides a fabric defect detection method, system, apparatus, and medium based on the RT-DETR model, comprising: Acquire sample knitted fabric images and construct a knitted fabric image dataset, which includes at least sample knitted fabric images, defect types, and defect areas; Based on the knitted fabric image dataset, feature sequences for training the fabric defect detection model are selected. The feature sequences are obtained by enhancing the texture differences of the defective areas in the image so that the ResNet18 network, which serves as the backbone network, can extract multi-scale features. The multi-scale features are then selected using a self-attention sparsity mechanism. An uncertainty minimization score is used to filter defect features from the feature sequence to generate defect categories and bounding boxes. A hybrid loss function is constructed to optimize the bounding box coordinates of the defects. Based on the feature sequence and the optimized bounding box coordinates, a fabric defect detection model based on the RT-DETR model is trained on the knitted fabric image dataset. Input the knitted fabric image to be detected into the trained fabric defect detection model and output the result.

[0011] The feature sequence filtering steps include: Enhance the texture difference between the defective region and other regions of the sample knitted fabric images in the knitted fabric image dataset, and extract and output the enhanced multi-scale features; Multiple scale features are filtered using a self-attention sparse method, and the filtered scale features are compensated using a dense self-attention method. Then, a lightweight cross-scale feature fusion method is used to perform feature interaction between features of different scales through a fusion operation, and a unified feature sequence corresponding to different defect types is output.

[0012] The step of enhancing the texture difference between the defective region and other regions of the sample knitted fabric images in the knitted fabric image dataset, and extracting and outputting the enhanced multi-scale features includes: Tensors of the images in the training set of data Decomposed into illuminance components and reflectivity components tensor satisfy:

[0013] in, For element-wise multiplication, For the illuminance perturbation term, This is the perturbation term for reflectivity; The illuminance components are learned separately through convolutional layers. and the reflectivity component Optimize the brightness and contrast of the defect area and enhance the texture difference between the defect and the texture; The illuminance component satisfy: The reflectivity component satisfy: ; in, , For convolution operations, , These are the corresponding learnable parameters; To amplify gradients in weak feature regions and suppress noise in knitted fabric textures, local features are corrected using depthwise convolution. The formula is as follows:

[0014] in, This is the enhanced feature map obtained after contrast optimization and feature fusion, where tanh is the activation function. It is a deep convolutional layer. These are learnable parameters; The backbone network extracts enhanced multi-scale features from the enhanced feature map. , , ,in, To focus on the detailed features of elongated defects, To focus on the semantic features of local defects, for.

[0015] The steps of filtering multiple scale features using a self-attention sparse method, compensating the filtered scale features based on a dense self-attention method, and then using a lightweight cross-scale feature fusion method to perform feature interaction between features of different scales through a fusion operation, and outputting a unified feature sequence corresponding to different defect types, include: Regarding the features Perform layer normalization and linear projection to generate the query matrix. Key matrix Value matrix The formula is:

[0016] Where Norm is the layer normalization function and Linear is the linear projection function. , , For learnable parameters, , , The dimension is , The number of feature points, For feature dimensions; The low-matching feature pairs corresponding to the knitted fabric texture are filtered out using an activation function, while defect-related features are retained. The formula is as follows:

[0017] in, For sparse self-attention functions, For normalization function, This is a learnable relative positional deviation; Branch compensation is achieved through dense self-attention, using the following formula:

[0018] Learning normalized weights and The dynamic balance between denoising and feature preservation is achieved using the following formula:

[0019] in, This is a fusion feature of sparse self-attention and dense self-attention. For dense self-attention functions, ; right , Cross-scale fusion is performed with the fused features to generate a unified feature sequence. The feature sequence The dimensions are: ,in, This represents the number of feature points after fusion.

[0020] The steps of filtering defects from the feature sequence using uncertainty minimization scoring, constructing a hybrid loss function to optimize the bounding box coordinates of the defects, and training a fabric defect detection model based on the RT-DETR model on the knitted fabric image dataset based on the feature sequence and the optimized bounding box coordinates include: Extract features at each scale from the unified feature sequence; Predict classification confidence for each scale feature; A fixed number of highest-scoring features are extracted using an uncertainty-minimizing scoring mechanism, and optimized features at each scale are output. Determine the defect category probability and defect bounding box coordinates based on the scale features and corresponding spatial locations; Based on the feature sequence and the optimized bounding box coordinates, a fabric defect detection model based on the RT-DETR model is trained on the knitted fabric image dataset. The initial object query includes at least target areas for broken yarn and holes; the preliminary category probability includes at least broken yarn, broken weft, stains, holes, and scratches.

[0021] The steps of training a fabric defect detection model based on the RT-DETR model on the knitted fabric image dataset based on the feature sequence and the optimized bounding box coordinates include: Construct prediction boxes respectively and real frame Two-dimensional Gaussian distribution and two-dimensional Gaussian distribution ; in, , , The coordinates of the center point on the x-axis of the prediction box. The coordinates of the center point of the prediction box along the y-axis. The height of the predicted bounding box, The width of the prediction box. The coordinates of the center point on the x-axis of the true bounding box. The coordinates of the center point of the true bounding box along the y-axis are... The actual height of the bounding box. The width of the actual bounding box. It is a diagonal matrix function; The bulldozer distances are calculated using the two-dimensional Gaussian distributions of the predicted bounding boxes and the two-dimensional Gaussian distributions of the ground truth bounding boxes, and then normalized using an exponential function. The formula is as follows:

[0022]

[0023] in, For the dataset correlation adjustment constant, Let be the bulldozer distance function. ; The weighted fusion of NWD loss and GIoU loss is expressed by the following formula:

[0024] in, The bounding box regression loss function is... These are the weighting coefficients. The traditional GIoU value; The optimizer minimizes the total loss, updates all learnable parameters of the model, and outputs the optimized defect bounding box coordinates, using the following formula:

[0025] in, For the total loss, This represents the cross-entropy loss.

[0026] The steps for inputting the knitted fabric image to be detected into the trained fabric defect detection model and outputting the results are as follows: output the results and save them to the ERP system record.

[0027] A fabric defect detection system based on the RT-DETR model includes: The acquisition module acquires sample knitted fabric images and constructs a knitted fabric image dataset, which at least includes sample knitted fabric images, defect types, and defect areas. The training module, based on the knitted fabric image dataset, filters the feature sequences for training the fabric defect detection model. The feature sequences are obtained by enhancing the texture differences of the defective areas in the image so that the ResNet18 network, which serves as the backbone network, can extract multi-scale features. The multi-scale features are then filtered using a self-attention sparsity mechanism. The optimization module uses uncertainty minimization scoring to filter defect features from the feature sequence to generate defect categories and bounding boxes, and constructs a hybrid loss function to optimize the bounding box coordinates of the defects. Based on the feature sequence and the optimized bounding box coordinates, a fabric defect detection model based on the RT-DETR model is trained on the knitted fabric image dataset. The output module takes the knitted fabric image to be detected, inputs it into the trained fabric defect detection model, and outputs the result.

[0028] A fabric defect detection device based on the RT-DETR model includes: a memory storing a fabric defect detection method program based on the RT-DETR model and a processor for running the fabric defect detection method program based on the RT-DETR model. The fabric defect detection method program based on the RT-DETR model is configured to implement the steps of the fabric defect detection method based on the RT-DETR model.

[0029] A computer-readable storage medium stores a fabric defect detection method program based on the RT-DETR model, wherein when the fabric defect detection method program based on the RT-DETR model is executed by a processor, the steps of the fabric defect detection method based on the RT-DETR model are implemented.

[0030] Compared with existing similar products, this invention is based on an improved RT-DETR architecture. Through precise improvements such as "IEL intensity enhancement layer to improve the contrast of weak features, ASSA adaptive sparse self-attention to filter texture noise, and NWD-GIoU hybrid loss function to optimize positioning accuracy", it has achieved a comprehensive improvement in detection accuracy, anti-interference ability, real-time performance and generalization ability compared with existing technologies. It effectively solves the core pain points in the detection of various types of defects such as broken yarns, broken wefts, stains, holes and scratches in knitted fabrics.

[0031] 1. Significantly improved detection accuracy: By strengthening weak feature representation through the IEL module, focusing effective information through the ASSA module, and optimizing the localization of small / slender defects through the NWD-GIoU hybrid loss function, the model's mAP@0.5 reaches 0.762, which is 6.2% higher than the baseline RT-DETRR18.

[0032] 2. Significantly enhanced anti-interference capability: To address interference such as knitted fabric texture noise and changes in workshop lighting, the false detection rate is controlled to within 5% through the adaptive sparse filtering of the ASSA module and the contrast enhancement mechanism of the IEL module.

[0033] 3. Balancing real-time performance with industrial applicability: The number of model parameters is reduced by 19.2% (from 19.88M to 16.51M), the computational load is reduced by 14.6% (from 57.0GFLOPs to 49.9GFLOPs), and the detection speed reaches 63.4 frames / s (single image processing time <16ms). It can be directly deployed on knitted fabric production lines to replace manual inspection. Attached Figure Description

[0034] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings.

[0035] Figure 1 This is a schematic diagram of the fabric defect detection method based on the RT-DETR model of the present invention. Detailed Implementation

[0036] To make the objectives, technical solutions, and beneficial effects of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0037] For ease of description, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified. In this application, unless otherwise explicitly stated and limited, the terms "installed," "connected," "linked," "fixed," etc., should be interpreted broadly. For example, they may refer to a fixed connection, a detachable connection, or an integral connection; a mechanical connection or an electrical connection; a direct connection or an indirect connection through an intermediate medium; or a connection within two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0038] Unless otherwise specified, the terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains, and the terms should be understood to have the meaning consistent with the meaning in the context of the relevant art, and should not be interpreted in an idealized or over-formalized manner, except as expressly defined in this invention.

[0039] like Figure 1 As shown, the computer program of this invention is based on an improved RT-DETR model. The working steps are executed sequentially as follows: "data input → feature extraction → feature interaction → decoding prediction → loss optimization → result output". The core improvement module is embedded in each step, as detailed below: Step 1: Data Input and Preprocessing The program reads a dataset of knitted fabric images (containing five types of defects: broken yarn, broken weft, stains, holes, and scratches), standardizes the images, and divides them into training, validation, and test sets in a 7:2:1 ratio. The training parameters are set as follows: batch size of 4, training epochs of 300, and the optimizer is AdamW (learning rate 0.0001, weight decay 0.0001, momentum 0.9).

[0040] Step 2: Backbone Network Feature Extraction Optimization: Backbone Network Feature Extraction Based on IEL An improved ResNet18 is used as the backbone network. An intensity enhancement layer (IEL) is embedded in the feature extraction stage of the backbone network. By decoupling image illumination and reflectivity, the contrast between weak feature defects (such as minor stains and scratches) and textured background of the knitted fabric is enhanced. The specific process is as follows: 2.2.1 Image decomposition based on Retinex theory: The input knitted fabric image tensor... (dimension is) , For height, For width, (Number of channels) decomposed into illuminance components and reflectivity components The decomposition model is as follows:

[0041] in, For element-wise multiplication, and These are perturbations for illuminance and reflectance, respectively, used to model illumination non-uniformity and noise interference from knitted fabric texture; 2.2.2 Component Learning and Feature Enhancement: Illuminance and reflectance components are learned through convolutional layers to focus on the brightness and texture differences in defective areas. The formula is as follows:

[0042] in, , For convolution operations, , For the corresponding learnable parameters, Used to optimize brightness and contrast in areas with defects. Used to enhance the texture difference between flaws and textures; 2.2.3 Contrast Optimization and Feature Fusion: The tanh activation function is used to amplify the gradient in weak feature regions and suppress knitted fabric texture noise. Local features are corrected through depthwise convolution. The formula is as follows:

[0043] in, It is a deep convolutional layer. As learnable parameters, this formula enhances defect features by amplifying the gradient of weak feature areas such as tiny stains and holes, while suppressing interference from regular textures. 2.2.4 Multi-scale feature output: Enhanced multi-scale features extracted from the backbone network , , (These correspond to semantic features and detail features at different levels, respectively), where Focus on the detailed characteristics of long and thin defects such as broken yarn and scratches. Focus on the semantic features of localized defects such as stains and holes, and input them into the subsequent encoder.

[0044] Step 3: Adaptive Sparse Self-Attention Optimization: Encoder Feature Interaction Based on ASSA Features output by the backbone network , , The input is a high-efficiency hybrid encoder, which replaces the original AIFI module with an adaptive sparse self-attention (ASSA) module to achieve texture noise filtering and effective defect feature focusing in knitted fabrics. The specific process is as follows: 3.3.1 Feature Projection and Normalization: For input features (dimension) Perform layer normalization and linear projection to generate the query matrix. Key matrix Value matrix Highlighting the differences in flaw features and texture:

[0045] Where Norm is the layer normalization operation and Linear is the linear projection. , , For learnable parameters, , , All dimensions ( The number of feature points, (for feature dimensions) 3.3.2 Sparse Self-Attention (SSA) Branch Denoising: Low-matching feature pairs corresponding to the knitted fabric texture are filtered out using an activation function, retaining only defect-related features. The formula is as follows:

[0046] in, The learnable relative positional deviation is used to improve the positional sensitivity to slender defects such as broken yarns and scratches, and to filter out redundant features of regular textures. 3.3.3 Dense Self-Attention (DSA) Branch Compensation: Considering all feature pairs, this avoids feature loss due to excessive sparsity, such as minor holes and slight stains. The formula is as follows:

[0047] 3.3.4 Dynamic Fusion of Two Branches: Learning Normalized Weights and ( Dynamically balances noise reduction and feature preservation to adapt to different types of knitted fabric defects:

[0048] 3.3.5 Cross-scale feature fusion: This is achieved through the CCFM module. , Cross-scale fusion with ASSA output features generates a unified feature sequence. (dimension) , (This is the number of feature points after fusion), which enhances the feature expression of defects of different shapes.

[0049] Step 4: Transformer decoder prediction feature sequence The input to the Transformer decoder selects a fixed number of high-quality initial object queries through an uncertainty minimization query selection mechanism, focusing on target areas such as broken yarn and holes. The decoder iteratively optimizes the output and, with the help of an auxiliary prediction head, directly outputs the preliminary category probability of defects (broken yarn / broken weft / stain / hole / scratch) and bounding box coordinates (without NMS post-processing).

[0050] Step 5: Loss Function Optimization: Model Optimization Based on NWD-GIoU Hybrid Loss A hybrid loss function integrating normalized Wasserstein distance (NWD) and GIoU is constructed to optimize positioning accuracy for special defects such as micro-holes and thin, broken yarns. The specific process is as follows: 5.5.1 Bounding box distribution modeling: Modeling the predicted bounding box and real frame ( , The coordinates of the center point, , Model the height and width as two-dimensional Gaussian distributions respectively. and Suitable for slim and long shapes ( or Larger ratios) and micro-sized ( , Distribution characteristics of defects with small numerical values; 5.5.2 NWD Distance Calculation: The second-order Wasserstein distance between two Gaussian distributions is calculated to accurately measure minute displacements and scale differences, and then normalized using an exponential function.

[0051]

[0052] in, The dataset correlation adjustment constant (in this invention) ), It is more sensitive to minute displacements of tiny holes and dimensional differences in broken yarns; 5.5.3 Construction of Hybrid Loss Function: Weighted fusion of NWD loss and GIoU loss to accommodate the localization needs of different morphological defects:

[0053] in, Weighting coefficients (in this invention) ), It uses the traditional GIoU value to ensure pixel-level overlap measurement of common defects such as stains and large holes; 5.5.4 Total Loss Optimization: Combining Classification Loss (Cross-entropy loss), the total loss is The AdamW optimizer minimizes the total loss and updates all learnable parameters of the model. , , , , , , wait).

[0054] Step 6: Output of detection results After the model training is completed, input the image of the knitted fabric to be detected. After processing through the above steps, output the category of defects (broken yarn / broken weft / stain / hole / scratch), bounding box coordinates and confidence score, and save it to the ERP system record to complete the knitted fabric defect detection.

[0055] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0056] The above description of the embodiments is provided to enable those skilled in the art to understand and use the present invention. It will be apparent to those skilled in the art that various modifications can be made to these embodiments, and the general principles described herein can be applied to other embodiments without inventive effort. Therefore, the present invention is not limited to the above embodiments, and any improvements and modifications made by those skilled in the art based on the disclosure of the present invention without departing from the scope of the invention should be within the protection scope of the present invention.

Claims

1. A fabric defect detection method based on the RT-DETR model, characterized in that, include: Acquire sample knitted fabric images and construct a knitted fabric image dataset, which includes at least sample knitted fabric images, defect types, and defect areas; Based on the knitted fabric image dataset, feature sequences for training the fabric defect detection model are selected. The feature sequences are obtained by enhancing the texture differences of the defective areas in the image so that the ResNet18 network, which serves as the backbone network, can extract multi-scale features. The multi-scale features are then selected using a self-attention sparsity mechanism. An uncertainty minimization score is used to filter defect features from the feature sequence to generate defect categories and bounding boxes. A hybrid loss function is constructed to optimize the bounding box coordinates of the defects. Based on the feature sequence and the optimized bounding box coordinates, a fabric defect detection model based on the RT-DETR model is trained on the knitted fabric image dataset. Input the knitted fabric image to be detected into the trained fabric defect detection model and output the result.

2. The fabric defect detection method based on the RT-DETR model according to claim 1, characterized in that, The feature sequence filtering steps include: Enhance the texture difference between the defective region and other regions of the sample knitted fabric images in the knitted fabric image dataset, and extract and output the enhanced multi-scale features; Multiple scale features are filtered using a self-attention sparse method, and the filtered scale features are compensated using a dense self-attention method. Then, a lightweight cross-scale feature fusion method is used to perform feature interaction between features of different scales through a fusion operation, and a unified feature sequence corresponding to different defect types is output.

3. The fabric defect detection method based on the RT-DETR model according to claim 2, characterized in that, The step of enhancing the texture difference between the defective region and other regions of the sample knitted fabric images in the knitted fabric image dataset, and extracting and outputting the enhanced multi-scale features includes: Tensors of the images in the training set of data Decomposed into illuminance components and reflectivity components tensor satisfy: in, For element-wise multiplication, For the illuminance perturbation term, This is the perturbation term for reflectivity; The illuminance components are learned separately through convolutional layers. and the reflectivity component Optimize the brightness and contrast of the defect area and enhance the texture difference between the defect and the texture; The illuminance component satisfy: The reflectivity component satisfy: ; in, , For convolution operations, , These are the corresponding learnable parameters; To amplify gradients in weak feature regions and suppress noise in knitted fabric textures, local features are corrected using depthwise convolution. The formula is as follows: in, This is the enhanced feature map obtained after contrast optimization and feature fusion, where tanh is the activation function. It is a deep convolutional layer. These are learnable parameters; The backbone network extracts enhanced multi-scale features from the enhanced feature map. , , ,in, To focus on the detailed features of large, elongated defects, The defect is of medium size. To focus on the semantic features of localized, minor flaws.

4. The fabric defect detection method based on the RT-DETR model according to claim 3, characterized in that, The steps of filtering multiple scale features using a self-attention sparse method, compensating the filtered scale features based on a dense self-attention method, and then using a lightweight cross-scale feature fusion method to perform feature interaction between features of different scales through a fusion operation, and outputting a unified feature sequence corresponding to different defect types, include: Regarding the features Perform layer normalization and linear projection to generate the query matrix. Key matrix Value matrix The formula is: Where Norm is the layer normalization function and Linear is the linear projection function. , , For learnable parameters, , , The dimension is , The number of feature points, For feature dimensions; The low-matching feature pairs corresponding to the knitted fabric texture are filtered out using an activation function, while defect-related features are retained. The formula is as follows: in, For sparse self-attention functions, For normalization function, This is a learnable relative positional deviation; Branch compensation is achieved through dense self-attention, using the following formula: Learning normalized weights and The dynamic balance between denoising and feature preservation is achieved using the following formula: in, This is a fusion feature of sparse self-attention and dense self-attention. For dense self-attention functions, ; right , Cross-scale fusion is performed with the fused features to generate a unified feature sequence. The feature sequence The dimensions are: ,in, This represents the number of feature points after fusion.

5. The fabric defect detection method based on the RT-DETR model according to claim 1, characterized in that, The steps of filtering defects from the feature sequence using uncertainty minimization scoring, constructing a hybrid loss function to optimize the bounding box coordinates of the defects, and training a fabric defect detection model based on the RT-DETR model on the knitted fabric image dataset based on the feature sequence and the optimized bounding box coordinates include: Extract features at each scale from the unified feature sequence; Predict classification confidence for each scale feature; A fixed number of highest-scoring features are extracted using an uncertainty-minimizing scoring mechanism, and optimized features at each scale are output. Determine the defect category probability and defect bounding box coordinates based on the scale features and corresponding spatial locations; A fabric defect detection model based on the RT-DETR model is trained on the knitted fabric image dataset based on the feature sequence and the optimized bounding box coordinates. The initial object query includes at least target areas for broken yarn and holes; the preliminary category probability includes at least broken yarn, broken weft, stains, holes, and scratches.

6. The fabric defect detection method based on the RT-DETR model according to claim 5, characterized in that, The steps of training a fabric defect detection model based on the RT-DETR model on the knitted fabric image dataset based on the feature sequence and the optimized bounding box coordinates include: Construct prediction boxes respectively and real frame Two-dimensional Gaussian distribution and two-dimensional Gaussian distribution ; in, , , The coordinates of the center point on the x-axis of the prediction box. The coordinates of the center point of the prediction box along the y-axis. The height of the predicted bounding box, The width of the prediction box. The coordinates of the center point on the x-axis of the true bounding box are... The coordinates of the center point of the true bounding box along the y-axis are... The actual height of the bounding box. The width of the actual bounding box. It is a diagonal matrix function; The bulldozer distance is calculated using the two-dimensional Gaussian distribution of the predicted bounding box and the two-dimensional Gaussian distribution of the ground truth bounding box, and then normalized using an exponential function. The formula is as follows: in, For the dataset correlation adjustment constant, Let be the bulldozer distance function. ; The weighted fusion of NWD loss and GIoU loss is expressed by the following formula: in, The bounding box regression loss function is... These are the weighting coefficients. The traditional GIoU value; The optimizer minimizes the total loss, updates all learnable parameters of the model, and outputs the optimized defect bounding box coordinates, using the following formula: in, For the total loss, This represents the cross-entropy loss.

7. The fabric defect detection method based on the RT-DETR model according to claim 1, characterized in that, The steps for inputting the knitted fabric image to be detected into the trained fabric defect detection model and outputting the results are as follows: output the results and save them to the ERP system record.

8. A fabric defect detection system based on the RT-DETR model, characterized in that, include: The acquisition module acquires sample knitted fabric images and constructs a knitted fabric image dataset, which includes at least sample knitted fabric images, defect types, and defect areas. The training module, based on the knitted fabric image dataset, filters the feature sequences for training the fabric defect detection model. The feature sequences are obtained by enhancing the texture differences of the defective areas in the image so that the ResNet18 network, which serves as the backbone network, can extract multi-scale features. The multi-scale features are then filtered using a self-attention sparsity mechanism. The optimization module uses uncertainty minimization scoring to filter defect features from the feature sequence to generate defect categories and bounding boxes, and constructs a hybrid loss function to optimize the bounding box coordinates of the defects. Based on the feature sequence and the optimized bounding box coordinates, a fabric defect detection model based on the RT-DETR model is trained on the knitted fabric image dataset. The output module takes the knitted fabric image to be detected, inputs it into the trained fabric defect detection model, and outputs the result.

9. A fabric defect detection device based on the RT-DETR model, characterized in that, include: The system includes a memory storing a fabric defect detection method program based on the RT-DETR model and a processor for running the fabric defect detection method program based on the RT-DETR model, wherein the fabric defect detection method program based on the RT-DETR model is configured to implement the steps of the fabric defect detection method based on the RT-DETR model as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, A computer-readable storage medium stores a fabric defect detection method program based on the RT-DETR model. When the fabric defect detection method program based on the RT-DETR model is executed by a processor, it implements the steps of the fabric defect detection method based on the RT-DETR model as described in any one of claims 1 to 7.