A broken warp and broken weft detection model and method based on cross fabric texture feature enhancement
By using a detection model enhanced with cross-fabric texture features and employing Fourier transform and self-attention mechanisms, the accuracy and cross-domain adaptability issues of complex texture feature detection are resolved. This enables efficient detection of warp and weft breaks, thereby improving the market competitiveness and product quality of textile enterprises.
Patent Information
- Application Number
- CN202411051820.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2044-08-01
AI Technical Summary
Existing technologies struggle to effectively handle complex texture features in fabric defect detection, especially warp and weft breaks. Furthermore, their generalization ability is insufficient when detecting defects across different domains, resulting in low detection accuracy and efficiency, which fails to meet the needs of textile companies to respond quickly to market changes.
A detection model based on cross-fabric texture feature enhancement is adopted. The fabric image texture enhancement module uses fast Fourier transform to highlight high-frequency texture information. Combined with the texture feature joint attention module and the defect category prototype adversarial module, adaptive feature extraction and feature alignment are achieved, which enhances the model's adaptability and detection capability in the target domain.
It improves the accuracy and generalization ability of fabric defect detection, enabling it to quickly adapt to new environments without requiring a large amount of labeled data, reducing data preparation costs, and improving production efficiency and product quality.
Smart Images

Figure CN119762414B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer vision and image processing, and particularly relates to a broken warp and weft detection model based on cross fabric texture feature enhancement and a detection method. BACKGROUND
[0002] In the field of textile manufacturing, automated fabric defect detection technology is crucial for ensuring product quality and production efficiency. Automated detection not only significantly improves detection speed and reduces labor costs, but also helps to avoid substandard products from entering the market, thereby protecting brand image and consumer rights and interests through accurate identification of defects.
[0003] Among the many possible fabric defects, broken warp and weft are two relatively common types of defects. Broken warp refers to the breakage of warp threads (i.e. threads perpendicular to the fabric edge) in the fabric. This usually occurs during the weaving process and may be caused by uneven warp tension, loom malfunction, or material quality issues. Broken warp not only affects the appearance of the fabric, but also may affect its structural strength and durability. Broken weft refers to the breakage of weft threads (i.e. threads parallel to the fabric edge) in the fabric. This may occur during weaving, dyeing, or post-processing. Causes of broken weft may include uneven weft tension or chemical damage during the dyeing process. These two defects are more common for the following four reasons:
[0004] 1. Mechanical stress in the production process: During weaving, warp and weft threads are subjected to high mechanical stress, especially under high-speed weaving or high tension conditions, which can easily lead to thread breakage.
[0005] 2. Material defects: Uneven quality or defects in raw materials (such as yarns) can also lead to thread breakage during weaving.
[0006] 3. Improper process control: Improper control of weaving process parameters (such as tension, speed, etc.) can increase the risk of thread breakage.
[0007] 4. Environmental factors: Changes in environmental conditions such as humidity and temperature can also affect the strength of the yarn, increasing the likelihood of thread breakage.
[0008] Therefore, in the fabric production process, detection and control of broken warp and weft are key links to ensure product quality, and the present application will focus on solving the problem of broken warp and weft detection in the fabric production process. Through an automated broken warp and weft defect detection system, these defects can be effectively identified and processed, thereby improving production efficiency and product quality.
[0009] With the development of computer vision technology, deep learning-based object detection methods have become an effective means to improve detection speed, accuracy, and generalization ability. Deep learning models, especially convolutional neural networks, have become the preferred technology for automated detection due to their superior performance in image recognition and classification tasks.
[0010] However, when there is a significant distribution difference between the training data (source domain) and the actual application scenario (target domain), these deep learning-based methods often encounter performance bottlenecks. The distribution shift between the source domain and the target domain can lead to a decline in the model's generalization ability in new environments, affecting the accuracy of detection. In this case, traditional detection algorithms, although stable under specific conditions, lack the generalization ability and adaptability when faced with diverse fabric textures and complex defect patterns. In addition, collecting and labeling a large amount of high-quality training data is not only time-consuming but also costly, which poses a challenge to the rapidly changing market demand and personalized product design. Under the trend of globalization and individualization of consumption, textile enterprises need to be able to respond quickly to market changes, and the limitations of automated detection technology limit the flexibility and competitiveness of enterprises.
[0011] To solve this problem, domain adaptation technology has emerged. The core idea of domain adaptation methods is to transfer knowledge from the source domain to the target domain to alleviate the problem of label scarcity in the target domain and improve the model's generalization ability in new environments. This method reduces the feature distribution difference between the source domain and the target domain, enhancing the model's adaptability to new environments. Although domain adaptation technology has made some progress in feature alignment, existing methods often ignore the intrinsic characteristics of images, especially when dealing with fabric images with rich texture information, their performance is limited by the ability to capture high-frequency detail features.
[0012] The complexity of fabric images mainly comes from their high-frequency texture information, which is manifested as rich high-frequency components in the frequency domain. High-frequency texture information is crucial for identifying subtle fabric broken warp and broken weft defects, as they can provide detailed information about the surface structure and texture changes of the fabric. However, traditional domain adaptation methods often struggle to effectively utilize these high-frequency information when dealing with such images, leading to performance degradation in cross-domain detection tasks. Existing research shows that deep neural networks tend to prioritize learning low-frequency information during training, which may lead to the loss of key high-frequency texture information during feature extraction in the case of scarce labeled data. Therefore, developing detection technology that can capture and utilize high-frequency texture information is of great significance to improve the accuracy and reliability of broken warp and broken weft detection.
[0013] Although Fourier transform has advantages in extracting high-frequency texture information, how to effectively integrate these information into deep learning models to achieve accurate detection of complex fabric broken warp and broken weft defects is still an open problem. Effectively mapping information in the frequency domain back to the spatial domain and combining it with the feature extraction mechanism of deep learning models requires innovative methods and techniques. In addition, designing a mechanism that allows the model to adaptively adjust its feature extraction strategy when processing data from different source and target domains to maximize the use of source domain knowledge and adapt to target domain characteristics is also a hot research topic. This not only involves algorithm design, but also includes in-depth study of model training and optimization strategies.
[0014] Although the field adaptation target detection technology has made progress in some aspects, there are still limitations in existing methods when dealing with fabric images with complex texture characteristics. These limitations not only affect the accuracy and efficiency of detection, but also limit the response speed of textile enterprises to market changes. Therefore, developing a cross-domain fabric broken warp and broken weft defect detection method that can effectively capture and utilize high-frequency texture information while having adaptive feature extraction capability has important practical significance for improving the accuracy and efficiency of automated detection in the textile manufacturing process. This not only can improve product quality and reduce production costs, but also can enhance the market competitiveness of enterprises and meet the needs of consumers for high-quality and personalized products.
[0015] There are also similar patent applications for fabric image defect detection:
[0016] Chinese invention patent application number CN202010030557.5 discloses a convolutional neural network fabric defect detection method based on extreme learning machine. This method constructs a convolutional neural network for feature extraction and fuses the extracted features. The fabric defect candidate box is extracted on the fused feature layer. In the fabric defect detection stage, the extracted fabric defect candidate box is regressed using a convolutional neural network, and the extreme learning machine is used to classify the fabric defect candidate box. The loss is calculated based on the classification and regression results combined with the real label of the sample picture. The weights in the network are updated using the stochastic gradient descent method based on the obtained loss, and the network is iteratively trained until the loss converges to a minimum value or reaches the preset training number of rounds. The trained fabric defect detection network model based on the extreme learning machine is obtained, which can be used for fabric defect detection.
[0017] Chinese invention patent application No. CN201310119567.6 discloses a warp knitting machine fabric flaw online visual detection method, which includes Gabor transform, feature extraction and flaw recognition, can realize real-time monitoring of warp knitting machine fabric and flaw shutdown; improves the shortcomings of traditional Gabor multi-scale decomposition fusion used in flaw detection field, such as large data calculation amount and information redundancy; automatically finds texture primitive period, so that the system can automatically segment the window for feature extraction.
[0018] Chinese invention patent application No. CN202111085311.9 proposes a fabric flaw recognition method and model training method. The model training method includes: detecting and processing the fabric through a preset model to obtain a detection result, which includes the flaw position of the first flaw detected by the preset model in the fabric and the flaw type of each first flaw. Obtain the corresponding label result of the fabric to be detected, which includes the flaw position of the second flaw labeled in the fabric and the type of each second flaw. According to the label result, determine the probability of each flaw type appearing in the fabric, and according to the detection result and the label result, determine the recognition accuracy of the preset model for each flaw type. According to the probability of each flaw type appearing in the fabric and the recognition accuracy of the preset model for each flaw type, determine the target sample.
[0019] Chinese invention patent application No. CN202310887250.0 discloses a small target fabric flaw detection method based on improved YOLOv5s, belonging to the technical field of machine vision detection. Obtain small target fabric flaw images and establish an initial data set; perform clustering analysis on the small target fabric flaw data set and obtain the clustering center; input the clustering center value into the YOLOv5s network; introduce the CA attention module into the YOLOv5s network to make the network pay attention in a larger area; use BiFPN structure as the feature fusion network of the YOLOv5s network model; use Eiou loss function instead of the original loss function.
[0020] The defects of the above invention patent applications are:
[0021] 1. The above invention belongs to a general fabric flaw detection method, which cannot effectively solve the problem of specific warp and weft flaw detection.
[0022] 2. These methods do not consider the detection generalization performance of the model in cross-domain scenarios when detecting flaw targets.
[0023] 3. These methods also do not pay attention to and utilize the rich texture details of fabric images, resulting in low accuracy in cross-domain fabric flaw detection.
[0024] And the problem targeted by the present application is more in line with the actual needs of the current industry, and has greater application prospects. SUMMARY
[0025] The present application aims to overcome the defects of the prior art, and provides a broken warp and broken weft detection model and method based on cross fabric texture feature enhancement.
[0026] A broken warp and broken weft detection model based on cross fabric texture feature enhancement is provided, the detection model comprising: a fabric image texture enhancement module, a texture feature joint attention module and a defect category prototype confrontation module, wherein the fabric image texture enhancement module converts the input image from the spatial domain to the frequency domain by using fast Fourier transform, and uses filter technology to highlight the high-frequency texture information in the image; the texture feature joint attention module is provided in the present application, which comprises: a deep learning of key areas and structural information in the image, which integrates the original image features and the features after texture enhancement processing through a self-attention mechanism, realizes adaptive weight adjustment of the key areas of the image, and enhances the detection ability of complex texture and defect areas; the defect category prototype confrontation module creates category prototypes of the source domain and the target domain, adopts the strategy of shortening and lengthening the feature distance, further aligns the feature distribution of the source domain and the target domain, and improves the generalization and adaptability of the model in the target domain.
[0027] The present application further provides a broken warp and broken weft detection method based on cross fabric texture feature enhancement, the detection method comprising the following specific steps:
[0028] Step 1. Collecting source domain fabric defect image dataset D S and target domain fabric defect image dataset D T , a domain feature extractor V A and an enhanced domain feature extractor V B are respectively initialized;
[0029] Step 2. Randomly sampling a source domain fabric image sample and a target domain fabric image sample The fabric image texture enhancement module is used to enhance the texture information of the source domain fabric image sample and the target domain fabric image sample , and the enhanced source domain image and the target domain image are obtained.
[0030] Step 3. The source domain fabric image and the target domain image are subjected to feature extraction by the domain feature extractor V A , and the enhanced source domain image and target domain images via domain enhanced feature extractor V B perform feature extraction;
[0031] Step 4. splice the source domain image and its texture enhanced image features output by the 3rd, 4th and 5th convolutional blocks of the domain enhanced feature extractor V A and the domain enhanced feature extractor V B , and the spliced features are classified by the gradient reversal layer and the domain classifier D to minimize the discrimination between the source domain and the target domain features;
[0032] Step 5. splice the image features output by the 5th convolutional block of the domain feature extractor V A and the enhanced domain feature extractor V B and its texture enhanced image features into joint features, which are input into the texture feature joint attention module to learn the connection between the original image and the texture enhanced image and to strengthen the model's attention to texture details;
[0033] Step 6. calculate the target detection loss of the source domain cloth image;
[0034] Step 7. calculate the defect target detection loss of the source domain cloth enhanced image;
[0035] Step 8. calculate the prototype of each class in the source domain using the source domain image labels, calculate the prototype of each class in the target domain using the pseudo labels of the target domain images and the pseudo labels of the texture enhanced images, and train the defect class prototype confrontation module by minimizing the distance between the prototypes of the same class in the source domain and the target domain and maximizing the distance between the prototypes of different classes in the source domain;
[0036] Step 9. calculate the overall target loss L TKG of the model and update the model parameters by backpropagation;
[0037] Step 10. repeat steps 2 to 9 until the maximum number of iterations I is reached or the model parameters converge;
[0038] Step 11. input the test picture into the trained cross-domain cloth defect detection model in the test inference stage of the model, and calculate the output defect area.
[0039] Further, in step 1, the source domain cloth defect image dataset D S and the target domain cloth defect image dataset D T , the domain feature extractor V A and the enhanced domain feature extractor V B are respectively initialized with parameters, and the specific steps are as follows:
[0040] Step 101, use a camera to capture and collect fabric defect images of the source domain and the target domain on an actual fabric production textile machine, ensure that each picture can clearly show the appearance of the fabric, represent the source domain as The target domain without label is represented as Wherein: represents the source domain fabric image, is the target domain image;
[0041] Step 102, label the defect area of the source domain image, represents the source domain image Corresponding label information, including boundary box coordinates And category
[0042] Step 103, set hyperparameters α, β, γ, η and the maximum number of iterations I, and use the pre-trained weight parameters on ImageNet to initialize the weights of the domain feature extractor V A And the enhanced domain feature extractor V B .
[0043] Further, in step 2, a source domain fabric image sample And a target domain fabric image sample Use the fabric image texture enhancement module to enhance the texture information of the source domain fabric image sample And the target domain fabric image sample And get the enhanced source domain image And the target domain image Enhance the texture of the source domain and the target domain image, the specific steps are:
[0044] Step 201, randomly sample a source domain picture And a target domain picture Input the fabric image texture enhancement module, for the input source domain image Wherein represents an original image with a height of H and a width of W, through Fourier transform, the frequency domain representation of the input image is obtained Where F represents the Fourier transform operation, specifically:
[0045]
[0046] In the above formula (1), j 2 =-1 is the imaginary unit, where X denotes the input source domain image, H denotes the height of the input image, W denotes the width of the input image, exp denotes the exponential function, Fourier transform decomposes the image into a combination of different frequency components, containing amplitude and phase information. The amplitude represents the strength of the signal, while the phase represents the position information of the signal;
[0047] Step 202, respectively introduce two functions F a and F p to represent the amplitude and phase components of the Fourier transform of the input image:
[0048]
[0049] In the above formula (2), is the frequency domain representation of the input image, |·| represents the modulus of the Fourier transform result of each pixel point, and arg() represents the phase of the Fourier transform result of each pixel point;
[0050] Step 203, in order to perform a high-pass filtering operation in the frequency domain space, define a mask function M β :
[0051]
[0052] In the above formula (3), M β (h,w) represents the value of the point at height h and width w on the mask, where the center position of the spectrum graph is taken as the center point (0,0), and β∈(0,1) is a parameter that controls the size of the center region of the mask. By using this mask, the high frequency components of the image are retained, and the low frequency components are removed, achieving enhancement of the texture;
[0053] Step 204, set the low frequency part in the Fourier transform amplitude information of the source domain image to zero to form a new frequency domain representation F shift :
[0054]
[0055] In the above formula (4), M β denotes the mask function, denotes the amplitude of the Fourier transform of the input image.
[0056] Step 205, convert the modified frequency domain image back to the spatial domain by inverse Fourier transform:
[0057]
[0058] In the above formula (5), FFT -1 denotes the inverse Fourier transform, F shiftrepresents a frequency domain representation of the input picture with low frequency parts of the amplitude information set to zero;
[0059] Step 206, for the input image from the target domain The corresponding converted image can also be obtained The image processed in this way is significantly enhanced in high-frequency texture information, which helps the model to detect more accurately in a complex texture background, and provides more rich feature information for the subsequent texture feature joint attention module and defect class prototype confrontation module.
[0060] Further, in step 3, the source domain cloth image and the target domain image are subjected to domain feature extraction by the domain feature extractor V A to enhance the source domain image and the target domain image are subjected to domain enhanced feature extraction by the domain enhanced feature extractor V B The specific steps are as follows:
[0061] Step 301, the input images of the source domain and the target domain A are subjected to feature extraction by the feature extractor V and The feature extractor V A contains 5 convolutional blocks, each of which consists of two convolutional layers, and the ReLU activation function is applied to introduce nonlinearity, so that the network can learn more complex feature representations. The output of the convolutional layer will then be passed to the next convolutional layer in the same convolutional block, or after the last convolutional layer, to the max-pooling layer. and After feature extraction, the output features of the 3rd, 4th and 5th convolutional blocks are retained, respectively, and are represented as and
[0062] Step 302, the texture enhanced images of the source domain and the target domain B are subjected to feature extraction by the feature extractor V and Similarly, the output features of the 3rd, 4th and 5th convolutional blocks are retained, respectively, and are represented as and
[0063] Further, in step 4, the domain feature extractor V A and the domain enhanced feature extractor V BThe source domain image features output by the 3rd, 4th and 5th convolutional blocks of V and the texture enhanced image features thereof are spliced, and the spliced features are classified by the gradient reversal layer and the domain classifier D to minimize the discrimination degree of the source domain and the target domain features, and the specific steps are as follows:
[0064] Step 401, first, the features of the source domain and the target domain image features are fused, and for V A and V B , the source domain image features output by the 3rd convolutional block of V and the texture enhanced image features thereof are spliced, and the spliced features are represented as Similarly, the spliced features of the 4th and 5th convolutional blocks are represented as
[0065] Step 402, the target domain image features output by V A and V B and the texture enhanced image features thereof are spliced, and the spliced features are represented as
[0066] Step 403, the domain adversarial loss is calculated, which is represented as:
[0067]
[0068] In the above formula (6), where L c is a cross-entropy loss function, denotes the spliced features of the mth convolutional block, where m e {3, 4, 5}, denotes the feature channel of the feature at (u, v), and m is the mth domain classifier parameter corresponding to the spliced feature, d i is the domain label of the current sample, the source domain is marked as 1, and the target domain is marked as 0, w m is the parameter of the backbone network corresponding to the current spliced feature.
[0069] Further, in step 5, the joint features of the image features output by the 5th convolutional block of the domain feature extractor V A and the enhanced domain feature extractor V B and the texture enhanced image features thereof are spliced and input to the texture feature joint attention module to learn the relationship between the original image and the texture enhanced image and to strengthen the model's attention to the texture details. The specific steps are as follows:
[0070] Step 501, V A and V BThe source domain image features output by the fifth convolutional block of the network and the texture enhanced image features thereof are spliced to obtain joint features defined as
[0071] In step 502, V A and V B The target domain image features output by the fifth convolutional block of the network and the texture enhanced image features thereof are spliced to obtain joint features defined as
[0072] In step 503, the spliced features are input into the texture feature joint attention module. First, an independent 1x1 convolution operation is used to map the input features to query (Q), key (K) and value (V) representations, wherein Q is an input vector used to calculate attention scores, K is used to calculate similarity with the query, a similarity matrix is obtained by calculating the similarity of Q and K at each position, and V is the actual input content. After the similarity of Q and K is calculated, V is weighted and combined according to the similarity. Here, a self-attention mechanism is used to generate feature representations after self-attention operation, so that the network can dynamically adjust the features according to the mutual correlation between different positions, so as to better capture complex textures and detailed information in the image. In order to ensure that the size of the generated features can adapt to the input requirements of the subsequent detection head, a 1x1 convolution is added to further reduce the dimensions of these features. The spliced features After passing through the texture feature joint attention module, output features
[0073] Further, in step 6, the target detection loss of the source domain cloth image is calculated, and the specific steps are as follows:
[0074] In step 601, for the input source domain cloth picture its classification loss is calculated
[0075]
[0076] In the above formula (7), N anchors represents the total number of predicted targets of the picture , i is the index of the predicted target, p = (p0, …, p K ) represents the prediction results of the model on the K categories of the ith predicted target, u = (u0, …, u K ) represents the labeled category, and if the target is the u-th category, u k = 1, and other values are 0. L cls represents the log loss between the labeled category and the predicted category. The labeled categories of all other categories except the correct category are 0, and L cls(p, u) = -log p;
[0077] Step 602, for the input source domain cloth picture Calculate its regression loss
[0078]
[0079] In the above formula (8), N anchors represents the total prediction target number of the picture , i is the index of the prediction target, t = (t x , t y , t W , t h ) represents the prediction result of the center point coordinate (t x , t y ), width t W and height t h of the regression frame of the i-th prediction target by the model, v = (v x , v y , v W , v h ) represents the labeled frame, and L loc represents the log loss between the labeled frame and the predicted frame:
[0080]
[0081] In the above formula (9), {x, y, w, h} represents the index of the regression frame, t = (t x , t y , t W , t h ) represents the prediction result of the center point coordinate (t x , t y ), width t W and height t h of the regression frame of the i-th prediction target by the model, v = (v x , v y , v W , v h ) represents the labeled frame, and L1 represents the absolute difference between two numerical values;
[0082] Step 603, calculate the target detection loss of the input source domain cloth picture :
[0083]
[0084] In the above formula (10), L represents the classification loss of the input source domain cloth picture , L represents the classification loss of the input source domain cloth picture The regression loss.
[0085] Further, in step 7, the defect detection loss of the source domain fabric enhancement image is calculated, specifically through the following steps:
[0086] Step 701: Similarly, according to equation (7), calculate the input source domain fabric enhancement image. Classification loss
[0087] Step 702: Similarly, according to equation (8), calculate the input source domain fabric enhancement image. regression loss
[0088] Step 703: Similarly, according to equation (9), calculate the input source domain fabric enhancement image. Target detection loss
[0089] Further, in step 8, the prototype of each category in the source domain is calculated using the source domain image labels, and the prototype of each category in the target domain data is calculated using the pseudo-labels of the target domain image and its texture-enhanced image. The loss of the defect category prototype adversarial module is calculated by minimizing the distance between prototypes of the same category in the source and target domains and maximizing the distance between prototypes of different categories in the source domain. The specific steps are as follows:
[0090] Step 801: To obtain the prototype of each category in the source domain, use the correct labels from the source domain. Features of the foreground region are extracted from the second fully connected layer of the region proposal layer. For the source domain image, the class prototype of its k-th class is calculated. The method is as follows:
[0091]
[0092] In equation (11) above, F(r) represents the characteristics of the foreground region r. Indicates category k in the source domain image The target quantity;
[0093] Step 802: For the target domain image The pseudo-label obtained by using the image through the detection head And the pseudo-labels obtained by the detection head after the texture-enhanced image is processed. Select pseudo-labels and pseudo-tags Prediction results with a confidence level greater than 0.5 are used as joint pseudo-labels y. uni And extract the joint pseudo-label y uni Similarly, the features of the corresponding foreground region, and the category prototype of each category k in the target domain. The calculation is as follows:
[0094]
[0095] In the above formula (12), F(r) represents the characteristics of the foreground region r, represents the number of instances of the class k in the target domain joint pseudo label y uni
[0096] Step 803, the calculation of the class prototype center in steps 801 and 802 above is performed within a training batch, in order to ensure the stability and consistency of the detection model, the existing class prototype needs to be updated when the next training iteration begins, and this process is achieved by the following way:
[0097]
[0098] In the above formula (13), the parameter a e (0, 1) is used to control the proportion of prototype updating, represents the prototype of the kth class at the ith iteration, represents the prototype of the kth class at the (i-1)th iteration;
[0099] Step 804, the goal of the flaw class prototype confrontation module is to minimize the Euclidean distance between the prototypes of the same class in the source domain and the target domain, and to maximize the Euclidean distance between the prototypes of different classes in the source domain, so as to promote the feature representation of the same class in the source domain and the target domain to be more similar, while the feature representation between different classes has higher discrimination, and the loss function of the flaw class prototype confrontation module is represented as:
[0100]
[0101] In the above formula (14), represents the class prototype of the kth class in the source domain at the ith iteration, represents the class prototype of the kth class in the target domain at the ith iteration, ||·|| 2 represents the calculation of the Euclidean distance, through the above mechanism, the flaw class prototype confrontation module can effectively align the feature representation between the source domain and the target domain, and enhance the detection ability of the model in the target domain.
[0102] Further, in step 9, the overall target loss of the calculation model is calculated The specific steps are as follows:
[0103]
[0104] In the above formula (15), represents the target detection loss of the source domain picture, a defect target detection loss representing a source domain cloth enhanced image, a domain adversarial loss, a loss of a defect category prototype adversarial module, and superparameters γ and η are used to balance different loss terms.
[0105] Further, in step 11, in the test inference stage of the model, the test picture is input into the cross-domain cloth defect detection model which is completed training, and the output defect area is calculated, and the specific steps are as follows:
[0106] In step 1101, the cloth defect image x of the target domain is input into the domain feature extractor V m The cloth image texture enhancement module is input into the image texture feature enhancement, and the texture enhanced image x
[0107] In step 1102, the original target domain cloth defect image x m And the texture enhanced image x Are input into the domain feature extractor V A And the enhanced domain feature extractor V B For feature extraction;
[0108] In step 1103, the source domain image features output by the fifth convolutional block of the V A And V B Network and the texture enhanced image features are spliced to obtain joint features And input into the texture feature joint attention module;
[0109] In step 1104, the features output by the texture feature joint attention module are sent to the region proposal layer for region suggestion, and finally the defect target detection is carried out through the detection head, and the detection result is output.
[0110] Compared with the prior art, the method has the following advantages:
[0111] 1. The method integrates the detail texture knowledge of the source domain and the target domain picture, solves the problem of performance decline of the traditional target detection model when facing distribution offset, and the innovative cross-domain detection framework design makes the model better adapt to new data distribution, improves the detection accuracy and generalization ability.
[0112] 2. The cloth image texture enhancement module used in the method selectively enhances the high-frequency texture information in the fabric image by using fast Fourier transform and high-pass filtering technology, not only improves the recognition ability of the detection model to complex texture features, but also removes the low-frequency components, so that the model can pay more attention to high-frequency details, thereby improving the detection precision.
[0113] 3. Advanced joint attention mechanism: The method introduces a texture feature joint attention module, which integrates the original image features and texture enhanced image features through a self-attention mechanism, emphasizes the key areas and internal relations in the image, and enables the detection model to adaptively adjust the weights of different regions and channels, enhances the attention to key textures and defect areas, and improves the defect detection capability of the model in complex backgrounds.
[0114] 4. The flaw category prototype adversarial module used in the method generates a category prototype center and adjusts the feature distance, realizes robust alignment of source domain and target domain features, reduces the distribution difference between the source domain and the target domain by pulling the prototype centers of the same category closer and pushing the prototype centers of different categories apart, thereby enhancing the detection performance and generalization ability of the model in the target domain.
[0115] 5. The method trains and detects effectively without labeling the target domain samples, and through the use of pseudo-labels and self-supervised learning techniques, the detection model can learn the features of the target domain without the assistance of human labeling, significantly reducing the cost and complexity of data preparation, improving the accuracy of detection, and enabling the detection model to quickly adapt to new application scenarios, which has significant industrial application value. BRIEF DESCRIPTION OF DRAWINGS
[0116] Figure 1 The flowchart of the method of the present application.
[0117] Figure 2 The framework diagram of the training stage of the method of the present application.
[0118] Figure 3 The framework diagram of the test inference stage of the method of the present application. DETAILED DESCRIPTION
[0119] In order to make the purpose, technical scheme and advantages of the method of the present application clearer, the specific embodiments of the detection model detection method of the present application will be further described in detail below with reference to the accompanying drawings.
[0120] Example 1
[0121] The detection model comprises a cloth image texture enhancement module, a texture feature joint attention module and a defect category prototype confrontation module, wherein the cloth image texture enhancement module converts an input image from a spatial domain to a frequency domain by using fast Fourier transform, and uses filter technology to highlight high-frequency texture information in the image; the texture feature joint attention module performs deep learning on key regions and structural information in the image, integrates original image features and features after texture enhancement processing through a self-attention mechanism, realizes adaptive weight adjustment of key regions of the image, and enhances the detection capability of complex textures and defect regions; the defect category prototype confrontation module creates category prototypes of the source domain and the target domain, uses a feature distance shortening and lengthening strategy, further aligns the feature distribution of the source domain and the target domain, and improves the generalization and adaptability of the model in the target domain.
[0122] Embodiment 2
[0123] The detection method comprises the following steps as shown in the figure: Figure 1 The detection method comprises the following steps as shown in the figure:
[0124] Step 1, collecting a source domain cloth defect image dataset D S and a target domain cloth defect image dataset D T , respectively initializing parameters of a domain feature extractor V A and an enhanced domain feature extractor V B .
[0125] Step 2, randomly sampling a source domain cloth image sample and a target domain cloth image sample , using a cloth image texture enhancement module to respectively perform texture information enhancement on the source domain cloth image sample and the target domain cloth image sample , and obtaining an enhanced source domain image and a target domain image .
[0126] Step 3, performing feature extraction on the source domain cloth image and the target domain image by using the domain feature extractor V A , performing feature extraction on the enhanced source domain image and the target domain image by using the domain enhanced feature extractor V B .
[0127] Step 4, using the domain feature extractor V A and the domain enhanced feature extractor V BThe source domain image and its texture enhanced image feature output by the 3rd, 4th and 5th convolution blocks are spliced, and the spliced features are classified by the gradient reversal layer and the domain classifier D to minimize the discrimination degree of the source domain and the target domain features.
[0128] Step 5, the domain feature extractor V A and the enhanced domain feature extractor V B The joint features of the image features output by the 5th convolution block and the texture enhanced image features thereof are input into the texture feature joint attention module to learn the connection between the original image and the texture enhanced image, and to strengthen the attention degree of the model to the texture details.
[0129] Step 6, the target detection loss of the source domain cloth image is calculated.
[0130] Step 7, the defect target detection loss of the source domain cloth enhanced image is calculated.
[0131] Step 8, the prototypes of each class in the source domain are calculated using the source domain image labels, and the prototypes of each class in the target domain data are calculated using the pseudo labels of the target domain images and the pseudo labels of the texture enhanced images thereof. The loss of the training calculation is performed by minimizing the distance between the prototypes of the same classes in the source domain and the target domain and maximizing the distance between the prototypes of different classes in the source domain.
[0132] In step 9, the overall target loss of the model
[0133] Step 10. Repeat steps 2 to 9 until the maximum number of iterations I is reached or the model parameters reach convergence.
[0134] Step 11, as shown in Figure 3 , in the test inference stage of the model, the test picture is input into the cross-domain cloth defect detection model completed by training, and the output defect area is calculated.
[0135] As an alternative embodiment, the specific steps of step 1 are:
[0136] Step 101, use a camera on an actual cloth production textile machine to capture and collect cloth defect images in the source domain and the target domain, ensuring that each picture clearly shows the appearance of the cloth. The source domain is represented as the target domain without labels is represented as wherein: represents the source domain cloth image, is the target domain image;
[0137] Step 102, label the defect area of the source domain image, represents the source domain image Corresponding label information, specifically including boundary box coordinates And category
[0138] Step 103, set hyperparameters a, b, g, h and the maximum number of iterations I, and initialize the domain feature extractor V using the pre-trained weight parameters on ImageNet A And enhance the weight of the domain feature extractor V B .
[0139] As an alternative embodiment, step 2 is specifically as follows:
[0140] Step 201, randomly sample a source domain picture And target domain picture And input the cloth image texture enhancement module, for the input source domain image Wherein Indicates an original image with a height of H and a width of W, and the frequency domain representation of the input image is obtained by Fourier transform Where F represents the Fourier transform operation, specifically:
[0141]
[0142] In the above formula (1), j 2 =-1 is the imaginary unit, Indicates the input source domain image, H indicates the height of the input image, W indicates the width of the input image, exp indicates the exponential function, and the Fourier transform decomposes the image into a combination of different frequency components, containing amplitude and phase information. The amplitude represents the strength of the signal, and the phase represents the position information of the signal;
[0143] Step 202, respectively introduce two functions F a And F p To represent the amplitude and phase components of the Fourier transform of the input image:
[0144]
[0145] In the above formula (2), Is the frequency domain representation of the input image, |·| represents the modulus of the Fourier transform result of each pixel point, and arg() represents the phase of the Fourier transform result of each pixel point;
[0146] Step 203, in order to perform a high-pass filtering operation in the frequency domain space, define a mask function M β :
[0147]
[0148] In the above formula (3), M β (h,w) represents the value of the point on the mask with height h and width w, where the center position of the spectrum diagram is taken as the center point (0,0), and β∈(0,1) is a parameter for controlling the size of the center area of the mask. By using the mask, the high-frequency components of the image are retained, and the low-frequency components are removed, so that the texture is enhanced.
[0149] Step 204, obtaining the source domain image The low-frequency part in the Fourier transform amplitude information is set to zero to form a new frequency domain representation F shift :
[0150]
[0151] In the above formula (4), M β represents the mask function, represents the amplitude of the Fourier transform of the input image.
[0152] Step 205, converting the modified frequency domain image back to the spatial domain by inverse Fourier transform:
[0153]
[0154] In the above formula (5), FFT -1 represents the inverse Fourier transform, F shift represents the frequency domain representation of the input image after setting the low-frequency part in the amplitude information to zero;
[0155] Step 206, for the input image from the target domain Similarly, the corresponding converted image can be obtained The image processed in this way is significantly enhanced in high-frequency texture information, which helps the model to detect more accurately in a complex texture background, and provides more rich feature information for the subsequent texture feature joint attention module and defect class prototype confrontation module.
[0156] As an alternative embodiment, the specific steps of step 3 are as follows:
[0157] Step 301, extracting features from the input image A from the source domain and the target domain by the feature extractor V and The feature extractor V A contains 5 convolutional blocks, each of which consists of two convolutional layers. The ReLU activation function is applied to introduce nonlinearity, so that the network can learn more complex feature representations. The output of the convolutional layer is then passed to the next convolutional layer in the same convolutional block, or after the last convolutional layer, it is passed to the max pooling layer. The input image and After feature extraction, the output features of the 3rd, 4th and 5th convolutional blocks are retained respectively, denoted as and
[0158] Step 302, the source domain and target domain image features are fused by the feature extractor V B The texture enhanced images of the source domain and target domain are and feature extraction, and the output features of the 3rd, 4th and 5th convolutional blocks are retained respectively, denoted as and
[0159] As an alternative embodiment, step 4 is specifically as follows:
[0160] Step 401, first, the source domain and target domain image features are fused, and for the source domain image features output by the 3rd convolutional block of V A and V B , the source domain image features output by the 3rd convolutional block of V and the texture enhanced image features thereof are spliced, and the spliced features are denoted as Similarly, the spliced features of the 4th and 5th convolutional blocks are denoted as
[0161] Step 402, the target domain image features output by V A and V B and the texture enhanced image features thereof are spliced, and the spliced features are denoted as
[0162] Step 403, the domain adversarial loss is calculated, denoted as:
[0163]
[0164] In the above formula (6), where L c is a cross-entropy loss function, denotes the spliced features of the mth convolutional block, where m e {3, 4, 5}, denotes the feature channel of the feature at (u, v), and θ m is the mth domain classifier parameter corresponding to the spliced feature, d i is the domain label of the current sample, the source domain is marked as 1, and the target domain is marked as 0, w m is the parameter of the backbone network corresponding to the current spliced feature.
[0165] As an alternative embodiment, step 5 is specifically as follows:
[0166] Step 501, VA and V B The source domain image features output by the fifth convolutional block of the network are spliced with the texture-enhanced image features thereof to obtain joint features defined as
[0167] Step 502, V A and V B The target domain image features output by the fifth convolutional block of the network are spliced with the texture-enhanced image features thereof to obtain joint features defined as
[0168] Step 503, the spliced features are input into the texture feature joint attention module. First, an independent 1x1 convolution operation is adopted to map the input features to query (Q), key (K) and value (V) representations, wherein Q is an input vector used to calculate attention scores, K is used to calculate similarity with the query, a similarity matrix is obtained by calculating the similarity of Q and K at each position, and V is the actual input content. After the similarity of Q and K is calculated, V is weighted and combined according to the similarity. Here, a self-attention mechanism is used to generate feature representations after self-attention operation, so that the network can dynamically adjust the features according to the mutual correlation between different positions, so as to better capture complex textures and detailed information in the image. In order to ensure that the size of the generated features can adapt to the input requirements of the subsequent detection head, a 1x1 convolution is added to further reduce the dimensions of these features. The spliced features are obtained after the texture feature joint attention module.
[0169] As an optional embodiment, step 6 is specifically as follows:
[0170] Step 601, for the input source domain cloth picture , calculate its classification loss
[0171]
[0172] In the above formula (7), N anchors represents the total number of prediction targets of the picture , i is the index of the prediction target, p = (p0, …, p K ) represents the prediction result of the model on the K categories of the i-th prediction target, u = (u0, …, u K ) represents the labeled category, if the target is the k-th category, u k = 1, and other values are 0, L cls represents the log loss between the labeled category and the predicted category. The labeled category of all other categories except the correct category is 0, then Lcls (p, u) = -log p;
[0173] Step 602, for the input source domain cloth picture Calculate its regression loss
[0174]
[0175] In the above formula (8), N anchors represents the total prediction target number of the picture , i is the index of the prediction target, t = (t x , t y , t W , t h ) represents the prediction result of the center point coordinate (t x , t y ), width t W and height t h of the regression frame of the i-th prediction target by the model, v = (v x , v y , v W , v h ) represents the labeled frame, L loc represents the log loss between the labeled frame and the predicted frame:
[0176]
[0177] In the above formula (9), {x, y, w, h} represents the index of the regression frame, t = (t x , t y , t W , t h ) represents the prediction result of the center point coordinate (t x , t y ), width t W and height t h of the regression frame of the i-th prediction target by the model, v = (v x , v y , v W , v h ) represents the labeled frame, L1 represents the absolute difference between two numerical values;
[0178] Step 603, calculate the target detection loss of the input source domain cloth picture :
[0179]
[0180] In the above formula (10), L represents the classification loss of the input source domain cloth picture , L the regression loss of the input source domain cloth picture the regression loss of the input source domain cloth picture
[0181] As an alternative embodiment, step 7 is specifically as follows:
[0182] Step 701, similarly according to formula (7), the classification loss of the input source domain cloth enhanced image the regression loss of the input source domain cloth enhanced image
[0183] Step 702, similarly according to formula (8), the regression loss of the input source domain cloth enhanced image the target detection loss of the input source domain cloth enhanced image
[0184] Step 703, similarly according to formula (9), the target detection loss of the input source domain cloth enhanced image the target detection loss of the input source domain cloth enhanced image
[0185] As an alternative embodiment, step 8 is specifically as follows:
[0186] Step 801, in order to obtain the prototype of each class in the source domain, the correct label of the source domain is used The features of the foreground region are extracted from the second full connection layer of the region proposal layer, and the class prototype of the kth class of the source domain image is calculated The method is as follows:
[0187]
[0188] In the above formula (11), F(r) represents the features of the foreground region r, represents the target number of class k in the source domain image ;
[0189] Step 802, for the target domain image The pseudo label obtained by passing the image through the detection head And the pseudo label obtained by passing the texture enhanced image of the image through the detection head Select the pseudo label And the pseudo label The prediction result with a confidence greater than 0.5 in the pseudo label and the pseudo label is selected as the joint pseudo label y uni , and the features of the foreground region corresponding to the joint pseudo label y uni The class prototype of each class k in the target domain is calculated in the same way The calculation method is as follows:
[0190]
[0191] In the above formula (12), F(r) represents the features of the foreground region r, represents the number of instances of class k in the target domain joint pseudo label y uni
[0192] The calculation of the class prototype center in steps 801 and 802 above is performed within a training batch. To ensure the stability and consistency of the detection model, the existing class prototype needs to be updated when the next training iteration begins. This is achieved by the following method:
[0193]
[0194] In the above formula (13), the parameter a e (0, 1) is used to control the proportion of prototype updating, represents the prototype of the kth class at the ith iteration, represents the prototype of the kth class at the (i-1)th iteration;
[0195] Step 804, the goal of the defect class prototype adversarial module is to minimize the Euclidean distance between the prototypes of the same class in the source domain and the target domain, while maximizing the Euclidean distance between the prototypes of different classes in the source domain, to promote the feature representation of the same class in the source domain and the target domain to be more similar, while the feature representation between different classes has higher discrimination. The loss function of the defect class prototype adversarial module is represented as:
[0196]
[0197] In the above formula (14), represents the class prototype of the kth class in the source domain at the ith iteration, represents the class prototype of the kth class in the target domain at the ith iteration, 2 represents the calculation of the Euclidean distance. Through the above mechanism, the defect class prototype adversarial module can effectively align the feature representation between the source domain and the target domain, and enhance the detection ability of the model in the target domain.
[0198] As an alternative embodiment, step 9 is specifically:
[0199]
[0200] In the above formula (15), represents the target detection loss of the source domain image, represents the defect target detection loss of the enhanced image of the source domain cloth, represents the domain adversarial loss, represents the loss of the defect class prototype adversarial module, and the hyperparameters γ and η are used to balance different loss terms.
[0201] As an alternative embodiment, asFigure 3 As shown, step 11 is specifically:
[0202] Step 1101, inputting the target domain fabric defect image x m The input fabric image texture enhancement module is used for image texture feature enhancement, and a texture enhanced image is obtained
[0203] Step 1102, inputting the original target domain fabric defect image x m and the texture enhanced image respectively into the domain feature extractor V A and the enhanced domain feature extractor V B for feature extraction;
[0204] Step 1103, splicing the source domain image features output by the fifth convolutional block of the V A and V B network and the texture enhanced image features to obtain joint features and input the texture feature joint attention module;
[0205] Step 1104, sending the features output by the texture feature joint attention module to the region proposal layer for region suggestion, finally passing through the detection head for defect target detection, and outputting the detection result.
[0206] In the implementation process of the model training of the present application, two images are input for each training batch, one from the source domain dataset and the other from the target domain dataset. In the training process, the random gradient descent method (SGD) with momentum of 0.9 and weight decay factor of 0.0005 is used to update the model parameters, the learning rate is initially set to 0.001, then it is reduced to 0.0001 in the first 30,000 iterations of model training, and the iteration training is continued for another 10,000 times. In addition, α is set to 0.1, β is set to 0.1, the hyperparameter γ is set to 0.1, and η is set to 1.0.
[0207] In order to measure the performance of the detection model and the detection method in the fabric defect target detection task, the fabric defect image data in actual production is tested, and the average precision mean (mAP) is used to objectively evaluate the performance of the model, specifically:
[0208] True Positive (TP): refers to the number of samples correctly predicted as positive by the model, for example, in defect detection, if the model detects defects and there are indeed defects, this will be counted as TP;
[0209] False Negative (FN): refers to the number of positive samples that the model incorrectly predicts as negative, in the context of defect detection, if the model fails to detect an actual existing defect, it will be counted as FN;
[0210] False Positive (FP): refers to the number of negative samples that the model incorrectly predicts as positive, in the context of defect detection, if the model incorrectly identifies a non-defective part as having a defect, it will be counted as FP;
[0211] True Negative (TN): refers to the number of samples that the model correctly predicts as negative, when the model correctly identifies the part of the image without defects, it will be counted as TN;
[0212] True Positive Rate (TPR) and False Positive Rate (FPR) are as follows:
[0213]
[0214] Precision and Recall are as follows:
[0215]
[0216] Recall = TPR,
[0217]
[0218] In the above formula, is a series of recall values, max(Precision) is the maximum precision value at each recall level, and mAP is obtained by averaging the AP values of all classes, mAP is a comprehensive index reflecting the overall performance of the model on different classes, mAP is calculated at different confidence thresholds, for example, mAP@0.5 represents the mAP when the confidence threshold is 0.5.
[0219] The detection method of the present application can accurately identify and locate various fabric defects, and has excellent generalization ability and adaptability, whether it is subtle texture change or obvious defect, the detection method of the present application can effectively capture, ensuring the high accuracy of the detection result; at the same time, the detection method of the present application can adaptively adjust the attention to different texture features, so as to realize stable detection performance in cross-domain scene.
[0220] The present application is not limited to the above-mentioned embodiments, and the above-mentioned embodiments and descriptions in the specification are only to illustrate the principles of the present application, and various changes and improvements can be made to the present application without departing from the spirit and scope of the present application, and such changes and improvements all fall within the scope of the claimed present application. The scope of protection of the present application is defined by the appended claims.
Claims
1. A warp and weft break detection system based on cross-domain fabric texture feature enhancement, the detection system comprising a cross-domain fabric defect detection model, the cross-domain fabric defect detection model comprising: a fabric image texture enhancement module, a texture feature joint attention module, and a defect category prototype adversarial module, wherein... The fabric image texture enhancement module uses Fast Fourier Transform to transform the input image from the spatial domain to the frequency domain and employs filter techniques to highlight high-frequency texture information in the image. The texture feature joint attention module performs deep learning on key regions and structural information in the image. Through a self-attention mechanism, it integrates the original image features and the features after texture enhancement, achieving adaptive weight adjustment for key regions of the image and enhancing the detection capability of complex textures and defect regions. The defect category prototype adversarial module creates category prototypes in the source and target domains and adopts a strategy of feature distance reduction and expansion to further align the feature distributions of the source and target domains, improving the model's generalization and adaptability in the target domain.
2. A detection method using the warp and weft breakage detection system based on cross-fabric texture feature enhancement as described in claim 1, comprising: Step 1. Collect a dataset of fabric defect images from the source domain. and target domain fabric defect image dataset Domain feature extractor and Enhanced Domain Feature Extractor Perform parameter initialization separately; Step 2. Randomly sample a source domain fabric image. A sample of fabric images in the target domain The fabric image texture enhancement module was used to enhance the texture of the source domain fabric image samples. and target domain fabric image samples Texture information enhancement is performed to obtain the enhanced source domain image. and target domain image Texture enhancement is performed on both the source and target domain images; Step 3. Source domain fabric image and target domain image samples After domain feature extractor Feature extraction is performed on the enhanced source domain image. and target domain image via augmentation domain feature extractor Perform feature extraction; Step 4. Use the domain feature extractor and Enhanced Domain Feature Extractor The source domain image output from the 3rd, 4th, and 5th convolutional blocks is concatenated with its texture-enhanced image features. The concatenated features are then passed through a gradient inversion layer and a domain classifier. Classification is performed to minimize the discriminative power of features between the source and target domains; Step 5. Use the domain feature extractor and Enhanced Domain Feature Extractor The joint feature obtained by concatenating the image features output by the 5th convolutional block and its texture-enhanced image features. , The input is fed into the texture feature joint attention module to learn the connection between the original image and the texture-enhanced image, thereby strengthening the model's attention to texture details; Step 6. Calculate the target detection loss for the source domain fabric image; Step 7. Calculate the defect detection loss for the source domain fabric-enhanced image; Step 8. Calculate the prototype of each category in the source domain using the source domain image labels, and calculate the prototype of each category in the target domain data using the pseudo-labels of the target domain image and its texture-enhanced image. Train the defect category prototype adversarial module by minimizing the distance between prototypes of the same category in the source domain and the target domain and maximizing the distance between prototypes of different categories in the source domain. Step 9. Calculate the overall target loss of the model. And backpropagate to update the model parameters; Step 10. Repeat steps 2 through 9 until the maximum number of iterations is reached. Or the model parameters have converged; Step 11. During the test inference phase of the model, input the test image into the trained cross-domain fabric defect detection model and calculate the output defect area.
3. According to the detection method of claim 2, in step 1, a dataset of source domain fabric defect images is collected. and target domain fabric defect image dataset Domain feature extractor and Enhanced Domain Feature Extractor The parameters are initialized separately, and the specific steps are as follows: Step 101: On an actual fabric production textile machine, use a camera to capture images of fabric defects in both the source and target domains, ensuring that each image clearly shows the appearance of the fabric. Represent the source domain as... Unlabeled target domains are represented as ,in: This represents a source domain fabric image sample. It is a target domain image sample; Step 102: Annotate the defective areas in the source image. Represents source domain fabric image samples The corresponding label information specifically includes bounding box coordinates. and categories ; Step 103: Set hyperparameters , , , and the maximum number of iterations It uses weight parameters pre-trained on ImageNet to initialize the domain feature extractor. and Enhanced Domain Feature Extractor The weight.
4. According to the detection method of claim 2, in step 2, a source domain fabric image sample is randomly sampled. A sample of fabric images in the target domain The fabric image texture enhancement module was used to enhance the texture of the source domain fabric image samples. and target domain fabric image samples Texture information enhancement is performed to obtain the enhanced source domain image. and target domain image Texture enhancement is performed on both the source and target domain images. The specific steps are as follows: Step 201: Randomly sample a source domain fabric image. and target domain image samples And input the fabric image texture enhancement module for the input source domain fabric image samples. ,in Indicates a height of Width is The original image is used to obtain the frequency domain representation of the input image through Fourier transform. ,in This represents the Fourier transform operation, specifically: ......(1), In the above formula (1), It is the imaginary unit. Indicates the height of the input image. Indicates the width of the input image. Representing an exponential function, the Fourier transform decomposes an image into a combination of different frequency components, including amplitude and phase information. Amplitude represents the signal intensity, while phase represents the signal's position information. Step 202: Introduce two functions respectively. and To represent the amplitude and phase components after the Fourier transform of the input image: ......(2), In the above formula (2), This is the frequency domain representation of the input image. This represents taking the modulus of the Fourier transform result for each pixel. This indicates taking the phase of the Fourier transform result for each pixel; Step 203: To perform high-pass filtering in the frequency domain, define a mask function. : ......(3), In the above formula (3), Indicates the height on the mask is Width is The value of the point at which the center point is located is taken as the center point of the spectrum. , It is a parameter that controls the size of the center region of the mask. Using this mask, the high-frequency components of the image are preserved and the low-frequency components are removed, thereby enhancing the texture. Step 204: Sample the source domain fabric image. The low-frequency portion of the Fourier transform amplitude information is set to zero, forming a new frequency domain representation. : ......(4), In the above formula (4), Represents the mask function. This represents the amplitude of the input image after Fourier transform; Step 205: Convert the modified frequency domain image back to the spatial domain using inverse Fourier transform: ......(5), In the above formula (5), Indicates the inverse Fourier transform. This represents the frequency domain representation of the input image after setting the low-frequency component of the amplitude information to zero. Step 206: For fabric image samples from the target domain Similarly, it is possible to obtain its corresponding converted image samples. The image processed in this way has significantly enhanced high-frequency texture information, which helps the model to detect more accurately in complex texture backgrounds and provides richer feature information for the subsequent texture feature joint attention module and defect category prototype adversarial module.
5. According to the detection method of claim 2, in step 3, the source domain fabric image sample and target domain fabric image samples After domain feature extractor Feature extraction is performed on the enhanced source domain image. and target domain image via augmentation domain feature extractor Feature extraction is performed, and the specific steps are as follows: Step 301: Using the domain feature extractor Input images for source and target domains and Feature extraction is performed using a domain feature extractor. It contains 5 convolutional blocks, each consisting of two convolutional layers. The ReLU activation function is applied to introduce non-linearity, enabling the network to learn more complex feature representations. The output of each convolutional layer is then passed to the next convolutional layer within the same block, or to a max-pooling layer after the last convolutional layer. This is applied to the input source domain fabric image samples. and target domain fabric image After feature extraction, the output features of the 3rd, 4th, and 5th convolutional blocks are retained, and are represented as follows: , , , , and ; Step 302: Enhanced domain feature extractor Texture enhancement images for source and target domains and Feature extraction is performed, retaining the output features of the 3rd, 4th, and 5th convolutional blocks, which are represented as follows: , , , , and .
6. According to the detection method of claim 2, in step 4, the domain feature extractor... and Enhanced Domain Feature Extractor The source domain image output from the 3rd, 4th, and 5th convolutional blocks is concatenated with its texture-enhanced image features. The concatenated features are then passed through a gradient inversion layer and a domain classifier. To perform classification and minimize the discriminative power of features between the source and target domains, the specific steps are as follows: Step 401: First, perform feature fusion on the source and target domain image features. and The source domain image features output by the third convolutional block and its texture enhancement image features The features are concatenated and the concatenated features are represented as follows: Similarly, the concatenation features of the 4th and 5th convolutional blocks are represented as follows: , ; Step 402, for and The output target domain image features and its texture-enhanced image features are concatenated, and the concatenated features are represented as follows: , , ; Step 403: Calculate the domain adversarial loss, expressed as: ......(6), In the above formula (6), ,in It is the cross-entropy loss function. Indicates the first The splicing features of each convolutional block, among which , This indicates that the feature is in The characteristic channel at the location, It is the first corresponding to this splicing feature. Domain classifier parameters, These are the domain labels of the current sample, with the source domain labeled as 1 and the target domain labeled as 0. These are the parameters of the backbone network corresponding to the current splicing feature.
7. According to the detection method of claim 2, in step 5, the domain feature extractor... and Enhanced Domain Feature Extractor The joint feature obtained by concatenating the image features output by the 5th convolutional block and its texture-enhanced image features. , The input image is fed into the joint attention module for texture features to learn the connection between the original image and the texture-enhanced image, thereby strengthening the model's attention to texture details. The joint attention learning process for the input image and its texture-enhanced image involves the following steps: Step 501, and The joint feature obtained by concatenating the source domain image features and its texture-enhanced image features output from the fifth convolutional block of the network is defined as follows: ; Step 502, and The joint feature obtained by concatenating the target domain image features output from the fifth convolutional block of the network with its texture-enhanced image features is defined as follows: ; Step 503: Splicing features , The input is fed into the joint attention module for texture features, using independent... The convolution operation maps the input features to a query Q, a key K, and a value V. Q is used as the input vector to calculate the attention score, K is used to calculate the similarity with the query, and a similarity matrix is obtained by calculating the similarity between Q and K at each position. V is the actual input content. After the similarity between Q and K is calculated, V is weighted and merged based on this similarity. This utilizes a self-attention mechanism to generate feature representations after the self-attention operation, allowing the network to dynamically adjust the features based on the interrelationships between different positions to better capture complex textures and details in the image. To ensure that the generated feature size can adapt to the input requirements of subsequent detection heads, a [missing information - likely a parameter or parameter] is added. Convolution is used to further reduce the dimensionality of these features, and features are concatenated. , After passing through the texture feature joint attention module, the output features are obtained respectively. , .
8. According to the detection method of claim 2, in step 6, the target detection loss of the source domain fabric image is calculated, specifically as follows: Step 601: For the input source domain fabric image sample Calculate its classification loss : ......(7), In the above formula (7), Represents source domain fabric image samples Total number of predicted targets It is the index of the predicted target. The model represents the first One prediction target in Prediction results for each category Indicates the label category; if the target is the first... Each category, then Other values are 0. This represents the log loss between the labeled category and the predicted category. If the labeled category is 0 for all categories other than the correct category, then... ; Step 602: For the input source domain fabric image sample Calculate its regression loss : ......(8), In the above formula (8), Represents source domain fabric image samples Total number of predicted targets It is the index of the predicted target. The model represents the first Coordinates of the center point of the regression bounding box for each prediction target ,width and height The prediction results Indicates a label box. The log loss between the labeled bounding box and the predicted bounding box is: ......(9), In the above formula (9), Indicates the index of the regression box. The model represents the first Coordinates of the center point of the regression bounding box for each prediction target ,width and height The prediction results Indicates a label box. This represents the absolute difference between two values; Step 603: Calculate the input source domain fabric image samples. Target detection loss: ......(10), In the above formula (10), This represents the input source domain fabric image sample. Classification loss, This represents the input source domain fabric image sample. The regression loss.
9. According to the detection method of claim 8, in step 7, the defect target detection loss of the source domain fabric enhancement image is calculated, specifically as follows: Step 701: Similarly, according to the above formula (7), calculate the input source domain fabric enhancement image. Classification loss ; Step 702: Similarly, according to the above formula (8), calculate the input source domain fabric enhancement image. regression loss ; Step 703: Similarly, according to the above formula (9), calculate the input source domain fabric enhancement image. Target detection loss .
10. According to the detection method of claim 2, in step 8, the prototype of each category in the source domain is calculated using the source domain image label, and the prototype of each category in the target domain data is calculated using the pseudo-label of the target domain image and the pseudo-label of its texture-enhanced image. The defect category prototype adversarial module is trained by minimizing the distance between prototypes of the same category in the source domain and the target domain and maximizing the distance between prototypes of different categories in the source domain. The specific steps are as follows: Step 801: To obtain the prototype of each category in the source domain, use the correct labels from the source domain. Features of the foreground region are extracted from the second fully connected layer of the region proposal layer for source domain fabric image samples. Calculate its first Category prototypes of each category The method is as follows: ......(11), In the above formula (11), Indicates the foreground area Features Indicates category Source domain fabric image samples The target quantity; Step 802: For the target domain fabric image sample The pseudo-label obtained by using the image through the detection head And the pseudo-labels obtained by the detection head after the texture-enhanced image is processed. Select pseudo tags and pseudo-tags Prediction results with a confidence level greater than 0.5 are used as joint pseudo-labels. And extract joint pseudo tags The corresponding features of the foreground region, and similarly, the features of each category in the target domain. Category prototype The calculation method is as follows: ......(12), In the above formula (12), Indicates the foreground area Features Indicates category Joint pseudo-labels in the target domain The number of instances in; Step 803: The calculation of the category prototype centers in steps 801 and 802 is performed within a training batch. To ensure the stability and consistency of the detection model, the existing category prototypes need to be updated at the start of the next training iteration. This process is achieved in the following way: ......(13), In the above equation (13), the parameter Used to control the proportion of prototype updates. Indicates the first During the nth iteration The prototype of each category, Indicates the first During the nth iteration The prototype of each category; Step 804: The goal of the defect category prototype adversarial module is to minimize the Euclidean distance between prototypes of the same category in the source and target domains, while maximizing the Euclidean distance between prototypes of different categories in the source domain. This aims to promote greater similarity in feature representations of the same category in the source and target domains, while also increasing the discriminative power of feature representations between different categories. The loss function of the defect category prototype adversarial module is expressed as: ......(14), In the above formula (14), Indicates the first The time source domain of the next iteration Category prototypes for each category, Indicates the first During the nth iteration, the target domain is... Category prototypes for each category, The above mechanism allows the defect category prototype adversarial module to effectively align the feature representations between the source and target domains, thereby enhancing the model's detection capability in the target domain. In step 9, the overall target loss of the model is calculated. The specific steps are as follows: ......(15), In the above formula (15), This represents the object detection loss of the source domain image. This represents the defect detection loss in the source domain fabric-enhanced image. Indicates domain adversarial loss, The loss of the prototype adversarial module representing the defect category, hyperparameters. and Used to balance different loss terms; In step 11, during the model's test inference phase, the test image is input into the trained cross-domain fabric defect detection model to calculate and output the defect region. The specific steps are as follows: Step 1101: Extract the fabric defect image from the target region. The fabric image texture enhancement module enhances the texture features of the image to obtain a texture-enhanced image. ; Step 1102: Extract the original target domain fabric defect image. and texture-enhanced images The inputs are respectively fed into the domain feature extractor. and Enhanced Domain Feature Extractor Perform feature extraction; Step 1103, and The source domain image features output from the fifth convolutional block of the network are concatenated with its texture-enhanced image features to obtain joint features. And input the texture feature joint attention module; Step 1104: The features output by the texture feature joint attention module are fed into the region proposal layer for region proposal, and finally the detection head is used to detect defect targets and output the detection results.
Citation Information
Patent Citations
Warp knitting machine cloth flaw on-line visual inspection method based on Gabor transformation
CN103234976A
A Convolutional Neural Network-Based Fabric Defect Detection Method Based on Extreme Learning Machine
CN111260614B
Methods for identifying fabric defects and model training methods
CN113807434B
Improved YOLOv5s small target cloth flaw detection method
CN117152484A
Cloth flaw identification method and model training method
CN113807434A