Cross-cloth texture feature enhancement-based broken warp and broken weft detection model and detection method

By introducing texture feature enhancement and joint attention mechanisms in the cloth image detection model, the problems of insufficient utilization of high-frequency texture information and insufficient generalization capabilities in the prior art are solved, and higher detection accuracy and adaptability are achieved.

CN119762414AActive Publication Date: 2025-04-04BEIJING INST OF TECH

Patent Information

Application Number
CN202411051820.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2025-04-04
Estimated Expiration
2044-08-01

AI Technical Summary

Technical Problem

The prior art is difficult to effectively utilize high-frequency texture information when processing cloth images, resulting in performance degradation in cross-domain detection tasks. The traditional method lacks generalization ability and adaptability when facing diverse fabric textures and complex defect patterns.

Method used

The detection model based on cross-fabric texture feature enhancement is adopted, including the cloth image texture enhancement module, the texture feature joint attention module and the defect category prototype adversarial module. High-frequency texture information is enhanced through fast Fourier transform and high-pass filtering technology, and the model's detection ability of complex textures and defective areas is enhanced through self-attention mechanisms and category prototype adversarial strategies.

Benefits of technology

It improves the accuracy and generalization ability of detection, can better adapt to new data distribution, enhances the ability to identify complex texture features, and improves detection accuracy and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119762414A_ABST
    Figure CN119762414A_ABST
Patent Text Reader

Abstract

The invention relates to a broken warp and broken weft detection model and detection method based on cross-cloth texture feature enhancement. The detection model comprises a cloth image texture enhancement module, a texture feature joint attention module and a flaw category prototype confrontation module. The detection method comprises the following steps: step 1, acquiring a source domain cloth flaw image data set DS and a target domain cloth flaw image data set DT, and respectively carrying out parameter initialization on a domain feature extractor VA and an enhanced domain feature extractor VB; step 2, randomly sampling a source domain cloth image sample # imgabs0 # and a target domain cloth image sample # imgabs1 #, and the like; the method has the advantages that by integrating detail texture knowledge of pictures of the source domain and the target domain, the problem that performance of a traditional target detection model is reduced when the traditional target detection model faces distribution offset is solved, and the model can better adapt to new data distribution due to the innovative cross-domain detection framework design; and the accuracy and generalization ability of detection are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer vision and image processing, and in particular to a warp and weft break detection model and a detection method based on cross-cloth texture feature enhancement. Background Art

[0002] In the field of textile manufacturing, automated cloth defect target detection technology is crucial to ensure product quality and production efficiency. Automated detection can not only significantly improve detection speed and reduce labor costs, but also help prevent unqualified products from entering the market by accurately identifying defects, thereby protecting brand image and consumer rights.

[0003] Among the many possible fabric defects, warp breakage and weft breakage are two of the more common types of defects. Warp breakage refers to the breakage of the warp threads (i.e. the threads perpendicular to the edge of the fabric) in the fabric. This usually occurs during the weaving process and may be caused by uneven warp tension, loom failure or material quality problems. Warp breakage not only affects the appearance of the fabric, but may also affect its structural strength and durability. Weft breakage refers to the breakage of the weft threads (i.e. the threads parallel to the edge of the fabric) in the fabric. This may occur during weaving, dyeing or post-processing. The causes of weft breakage may include uneven weft tension or chemical damage during the dyeing process. There are four reasons why these two defects are more common:

[0004] 1. Mechanical stress during the production process: During the weaving process, the warp and weft threads will be subjected to greater 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 yarn) may also lead to thread breakage during the weaving process.

[0006] 3. Improper process control: Improper control of weaving process parameters (such as tension, speed, etc.) may increase the risk of thread breakage.

[0007] 4. Environmental factors: Changes in environmental conditions such as humidity and temperature may also affect the strength of the yarn, thereby increasing the possibility of breakage.

[0008] Therefore, in the process of cloth production, the detection and control of warp and weft breakage is a key link to ensure product quality. The present invention will also focus on solving the problem of warp and weft breakage detection in the process of cloth production. Through an automated warp and weft breakage 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, object detection methods based on deep learning 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 excellent performance in image recognition and classification tasks.

[0010] However, these deep learning-based methods often encounter performance bottlenecks when there is a significant distribution difference between the training data (source domain) and the actual application scenario (target domain). The distribution shift between the source and target domains may lead to a decrease in the generalization ability of the model in a new environment, thereby affecting the accuracy of detection. In this case, although traditional detection algorithms are stable under specific conditions, they lack generalization and adaptability when faced with diverse fabric textures and complex defect patterns. In addition, collecting and annotating a large amount of high-quality training data is not only time-consuming but also costly, which poses a challenge to rapidly changing market demands and personalized product design. Under the trend of globalization and personalized consumption, textile companies need to be able to respond quickly to market changes, and the limitations of automated detection technology restrict the flexibility and competitiveness of companies.

[0011] To solve this problem, domain adaptation technology came into being. The core idea of ​​domain adaptation methods is to transfer knowledge from the source domain to the target domain to alleviate the problem of missing target domain labels and improve the generalization ability of the model in new environments. This method enhances the adaptability of the model to new environments by reducing the difference in feature distribution between the source domain and the target domain. Although domain adaptation technology has made some progress in feature alignment, existing methods often ignore the intrinsic characteristics of images, especially when processing 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 warp and weft breaks in fabrics because it can provide detailed information about the surface structure and texture changes of the fabric. However, traditional domain adaptation methods often find it difficult to effectively utilize this high-frequency information when processing such images, resulting in performance degradation in cross-domain detection tasks. Existing studies have shown that deep neural networks tend to prioritize learning low-frequency information during training, which may cause the model to lose key high-frequency texture information during feature extraction when labeled data is scarce. Therefore, developing detection technology that can capture and utilize high-frequency texture information is of great significance for improving the accuracy and reliability of warp and weft break detection.

[0013] Although Fourier transform has advantages in extracting high-frequency texture information, how to effectively integrate this information into deep learning models to achieve accurate detection of complex fabric defects such as broken warp and weft 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 technologies. In addition, designing a mechanism that enables the model to adaptively adjust its feature extraction strategy when processing different source and target domain data to maximize the use of source domain knowledge and adapt to target domain characteristics is also a hot topic of current research. This involves not only the design of the algorithm, but also an in-depth study of model training and optimization strategies.

[0014] Although domain adaptive object detection technology has made progress in some aspects, existing methods still have limitations when processing fabric images with complex texture features. These limitations not only affect the accuracy and efficiency of detection, but also limit the speed at which textile companies can respond to market changes. Therefore, developing a cross-domain cloth broken warp and weft defect detection method that can effectively capture and utilize high-frequency texture information and has adaptive feature extraction capabilities is of great practical significance for improving the accuracy and efficiency of automated detection in the textile manufacturing process. This can not only improve product quality and reduce production costs, but also enhance the market competitiveness of enterprises and meet consumers' demand for high-quality and personalized products.

[0015] There are similar patent applications for cloth image defect detection:

[0016] Chinese invention patent application No. CN202010030557.5 discloses a convolutional neural network cloth defect detection method based on an extreme learning machine. The method constructs a convolutional neural network for feature extraction, fuses the extracted features, extracts cloth defect candidate frames on the fused feature layer, and in the cloth defect detection stage, uses a convolutional neural network to regress the extracted cloth defect candidate frames, uses an extreme learning machine to classify the cloth defect candidate frames, calculates the loss of the classification and regression results combined with the true label of the sample image, and uses the stochastic gradient descent method based on the obtained loss to update the weights in the network. The training is continuously iterated until the network loss converges to a minimum value or reaches a preset number of training rounds, so as to obtain a trained network model for cloth defect detection based on the extreme learning machine, and cloth defect detection can be performed.

[0017] Chinese invention patent application number CN201310119567.6 discloses an online visual detection method for warp knitting machine fabric defects, including Gabor transformation, feature extraction and defect recognition, which can realize real-time monitoring of warp knitting machine fabrics and defect shutdown; improves the shortcomings of traditional Gabor multi-scale decomposition and fusion for defect detection, such as large amount of data calculation and information redundancy; automatically searches for texture primitive periods so that the system can automatically split windows for feature extraction.

[0018] Chinese invention patent application number CN202111085311.9 proposes a defect recognition method and model training method for cloth. The model training method includes: detecting and processing the cloth through a preset model to obtain a detection result, and the detection result includes: the defect position of the first defect detected by the preset model in the cloth, and the defect type of each first defect. Obtain the labeling result corresponding to the cloth to be detected, and the labeling result includes the defect position of the marked second defect in the cloth, and the type of each second defect. According to the labeling result, determine the probability of defects of each defect type appearing in the cloth, and according to the detection result and the labeling result, determine the recognition accuracy of the preset model for each defect type. Determine the target sample according to the probability of defects of each defect type appearing in the cloth and the recognition accuracy of the preset model for each defect type.

[0019] Chinese invention patent application number CN202310887250.0 discloses a small target cloth defect detection method based on improved YOLOv5s, which belongs to the field of machine vision detection technology. The method obtains a small target cloth defect image and establishes an initial data set; performs cluster analysis on the small target cloth defect data set and obtains the cluster center; inputs the cluster center value into the YOLOv5s network; introduces a CA attention module into the YOLOv5s network to enable the network to pay attention to a larger area; adopts a BiFPN structure as a feature fusion network of the YOLOv5s network model; and adopts an Eiou loss function instead of the original loss function.

[0020] The defects of the above invention patent application are:

[0021] 1. The above invention is a general cloth defect detection method and cannot effectively solve the problem of detecting specific warp and weft break defects.

[0022] 2. These methods do not consider the detection generalization performance of the model in cross-domain scenarios when detecting defective objects.

[0023] 3. These methods also fail to pay attention to and utilize the rich texture details of cloth images, resulting in low accuracy in cross-domain cloth defect detection.

[0024] The problem addressed by the present invention is more in line with the actual needs of the current industry and has greater application prospects. Summary of the invention

[0025] The purpose of the present invention is to overcome the defects of the prior art and provide a warp and weft break detection model and detection method based on cross-cloth texture feature enhancement.

[0026] A warp and weft break detection model based on cross-cloth texture feature enhancement is provided, and 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 adopts fast Fourier transform to convert the input image from the spatial domain to the frequency domain, and uses filter technology to highlight the high-frequency texture information in the image; the texture feature joint attention module implements deep learning of key areas and structural information in the image, integrates the original image features and the features processed by texture enhancement through a self-attention mechanism, realizes adaptive weight adjustment of the key areas of the image, and enhances the detection capability of complex textures and defective areas; the defect category prototype confrontation module creates category prototypes of the source domain and the target domain, adopts the strategy of feature distance pulling closer and farther, 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 invention further provides a method for detecting broken warps and wefts based on cross-cloth texture feature enhancement, the detection method comprising the following specific steps:

[0028] Step 1. Collect source domain cloth defect image dataset D S And the target domain cloth defect image dataset D T , domain feature extractor V A and enhanced domain feature extractor V B Initialize parameters respectively;

[0029] Step 2. Randomly sample a source domain cloth image sample and a target domain cloth image sample Use the cloth image texture enhancement module to respectively And the target domain cloth image samples Enhance the texture information and obtain the enhanced source domain image and the target domain image Perform texture enhancement on source and target domain images;

[0030] Step 3. Source domain cloth image and the target domain image After the domain feature extractor V A Feature extraction and enhanced source domain image and the target domain image Via domain-enhanced feature extractor V B Perform feature extraction;

[0031] Step 4. Use the domain feature extractor V A and domain enhanced feature extractor V B The source domain image and its texture enhanced image features output by the 3rd, 4th, and 5th convolutional blocks are concatenated, and the concatenated 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. Use the domain feature extractor V A and enhanced domain feature extractor V B The joint feature of the image feature output by the 5th convolutional block and its texture enhanced image feature The input is sent to 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 object detection loss of the source domain cloth image;

[0034] Step 7. Calculate the defect object detection loss of the source domain cloth enhanced image;

[0035] Step 8. Use the source domain image label to calculate the prototype of each category in the source domain, use the pseudo label of the target domain image and the pseudo label of its texture enhanced image to calculate the prototype of each category of the target domain data, and train the defect category prototype adversarial module by minimizing the distance between the prototypes of the same category in the source domain and the target domain and maximizing the distance between the prototypes of different categories in the source domain;

[0036] Step 9. Calculate the overall objective loss L of the model TKG , and back-propagate to update the model parameters;

[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. In the test reasoning phase of the model, the test image is input into the trained cross-domain cloth defect detection model to calculate and output the defect area.

[0039] Furthermore, in step 1, a source domain cloth defect image dataset D is collected. S And the target domain cloth defect image dataset D T , domain feature extractor V A and enhanced domain feature extractor V B Initialize the parameters respectively. The specific steps are as follows:

[0040] Step 101: Use a camera on an actual cloth production textile machine to capture cloth defect images in the source domain and the target domain, ensuring that each image can clearly show the appearance of the cloth. The source domain is represented as The unlabeled target domain is represented as in: represents the source domain cloth image, is the target domain image;

[0041] Step 102: marking defective areas of the source domain image. Represents the source domain image The corresponding label information, including the bounding box coordinates and categories

[0042] Step 103: Set hyperparameters α, β, γ, η and the maximum number of iterations I, and use the weight parameters pre-trained on ImageNet to initialize the domain feature extractor V. A and enhanced domain feature extractor V B The weight of .

[0043] Furthermore, in step 2, a source domain cloth image sample is randomly sampled and a target domain cloth image sample Use the cloth image texture enhancement module to respectively And target domain cloth image samples Enhance the texture information and obtain the enhanced source domain image and the target domain image Texture enhancement is performed on source and target domain images. The specific steps are as follows:

[0044] Step 201: Randomly sample a source domain image and the target domain image And input the cloth image texture enhancement module, for the input source domain image in 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, Represents the input source domain image, H represents the height of the input image, W represents the width of the input image, and exp represents the exponential function. The Fourier transform decomposes the image into a combination of different frequency components, including amplitude and phase information. The amplitude represents the strength of the signal, while the phase represents the location information of the signal;

[0047] Step 202: Introduce two functions F respectively a and F p To represent the amplitude and phase components of the input image after Fourier transformation:

[0048]

[0049] In the above formula (2), is the frequency domain representation of the input image, |·| represents taking the modulus of the Fourier transform result of each pixel, and arg() represents taking the phase of the Fourier transform result of each pixel;

[0050] Step 203: In order to perform high-pass filtering in the frequency domain, a mask function M is defined. β :

[0051]

[0052] In the above formula (3), M β (h,w) represents the value of the point on the mask with a height of h and a width of w. Here, the center of the spectrum is taken as the center point (0,0). β∈(0,1) is a parameter that controls the size of the center area of ​​the mask. Using this mask, the high-frequency components of the image are retained and the low-frequency components are removed to enhance the texture.

[0053] Step 204: The source domain image The low-frequency part of the Fourier transformed amplitude information is set to zero, forming a new frequency domain representation F shift :

[0054]

[0055] In the above formula (4), M β represents the mask function, Represents the amplitude of the input image after Fourier transformation.

[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 represents the inverse Fourier transform, F shiftrepresents the frequency domain representation of the input image after the low-frequency part of the amplitude information is set to zero;

[0059] Step 206: For an input image from the target domain The corresponding conversion image can also be obtained The images processed in this way have their high-frequency texture information significantly enhanced, 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.

[0060] Furthermore, in step 3, the source domain cloth image and the target domain image After the domain feature extractor V A Feature extraction and enhanced source domain image and the target domain image Via domain-enhanced feature extractor V B Perform feature extraction. The specific steps are:

[0061] Step 301: Through feature extractor V A Input images of source and target domains and Perform feature extraction, feature extractor V A It contains 5 convolution blocks, each of which consists of two convolution layers. The ReLU activation function is used to introduce nonlinearity, so that the network can learn more complex feature representations. The output of the convolution layer is then passed to the next convolution layer in the same convolution block, or to the maximum pooling layer after the last convolution layer. and After feature extraction, the output features of the 3rd, 4th, and 5th convolutional blocks are retained, respectively, and are expressed as and

[0062] Step 302: Through feature extractor V B Texture-enhanced images for source and target domains and For feature extraction, the output features of the 3rd, 4th, and 5th convolutional blocks are also retained, which are represented as and

[0063] Furthermore, in step 4, the domain feature extractor V A and domain enhanced feature extractor V BThe source domain image and its texture enhanced image features output by the 3rd, 4th, and 5th convolutional blocks are spliced, 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. The specific steps are as follows:

[0064] Step 401: First, the source domain and target domain image features are fused. A and V B The source domain image features output by the third convolutional block and its texture enhanced image features After splicing, the features after splicing are expressed as Similarly, the concatenated features of the 4th and 5th convolutional blocks are expressed as

[0065] Step 402: V A and V B The output target domain image features and its texture enhanced image features are spliced, and the spliced ​​features are expressed as

[0066] Step 403: Calculate the domain adversarial loss, expressed as:

[0067]

[0068] In the above formula (6), Where L c is the cross entropy loss function, represents the concatenated features of the mth convolutional block, where m∈{3,4,5}, represents the feature channel of the feature at (u,v), θ m is the mth domain classifier parameter corresponding to the concatenated feature, d i is the domain label of the current sample, the source domain is marked as 1, the target domain is marked as 0, and w m It is the parameter of the backbone network corresponding to the current splicing feature.

[0069] Furthermore, in step 5, the domain feature extractor V A and enhanced domain feature extractor V B The joint feature of the image feature output by the 5th convolutional block and its texture enhanced image feature Input to the texture feature joint attention module to learn the connection between the original image and the texture enhanced image, and strengthen the model's attention to texture details. The input image and its texture enhanced image are jointly learned by attention. The specific steps are:

[0070] Step 501: V A and V BThe source domain image features and its texture enhanced image features output by the 5th convolutional block of the network are concatenated, and the resulting joint features are defined as

[0071] Step 502: V A and V B The target domain image features output by the fifth convolutional block of the network are concatenated with the texture-enhanced image features, and the resulting joint features are defined as

[0072] Step 503: Splice features Input into the texture feature joint attention module, first use an independent 1×1 convolution operation to map the input features to query (Q), key (K) and value (V) representations, where Q is the input vector used to calculate the attention score, K is used to calculate the similarity with the query, and the similarity matrix is ​​obtained by calculating the similarity of Q and K at each position. V is the actual input content. When the similarity calculation of Q and K is completed, V will be weighted and merged according to the similarity. The self-attention mechanism is used here to generate feature representations after the self-attention operation, so that the network can dynamically adjust the features according to the correlation between different positions to better capture the complex texture and detail information in the image. To ensure that the generated feature size can meet the input requirements of the subsequent detection head, a 1×1 convolution is added to further reduce the dimension of these features and splice the features. After the texture feature joint attention module, the output features are obtained respectively.

[0073] Furthermore, in step 6, the object detection loss of the source domain cloth image is calculated, and the specific steps are as follows:

[0074] Step 601: for the input source domain cloth image Calculate its classification loss

[0075]

[0076] In the above formula (7), N anchors Display pictures The total number of predicted targets, i is the index of the predicted target, p = (p0, ..., p K ) represents the prediction result of the model for the i-th prediction target on K categories, u=(u0,…,u K ) represents the labeled category. If the target is the u-th category, then u k =1, other values ​​are 0, L cls represents the logarithmic loss between the labeled category and the predicted category. All the labeled categories except the correct category are 0, then L cls(p,u) = -logp;

[0077] Step 602: for the input source domain cloth image Calculate its regression loss

[0078]

[0079] In the above formula (8), N anchors Display pictures The total number of predicted targets, i is the index of the predicted target, t = (t x ,t y ,t W ,t h ) represents the coordinates of the center point of the i-th predicted target regression box (t x ,t y ), width t W and height t h The prediction result, v = (v x ,v y ,v W ,v h ) indicates a label box, L loc Represents the logarithmic loss between the annotation box and the prediction box:

[0080]

[0081] In the above formula (9), {x, y, w, h} represents the index of the regression box, t = (t x ,t y ,t W ,t h ) represents the coordinates of the center point of the i-th predicted target regression box (t x ,t y ), width t W and height t h The prediction result, v = (v x ,v y ,v W ,v h ) represents the label box, L1 represents the absolute difference between two values;

[0082] Step 603: Calculate the input source domain cloth image The target detection loss is:

[0083]

[0084] In the above formula (10), Represents the input source domain cloth image The classification loss is Represents the input source domain cloth image The regression loss.

[0085] Furthermore, in step 7, the defect object detection loss of the source domain cloth enhanced image is calculated, and the specific steps are as follows:

[0086] Step 701: Similarly, according to formula (7), the input source domain cloth enhancement image is calculated The classification loss

[0087] Step 702: Similarly, according to formula (8), the input source domain cloth enhancement image is calculated: The regression loss

[0088] Step 703: Similarly, according to formula (9), the input source domain cloth enhancement image is calculated: The target detection loss

[0089] Furthermore, 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 of 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 loss calculation of the defect category prototype adversarial module is performed by minimizing the distance between the prototypes of the same category in the source domain and the target domain and maximizing the distance between the prototypes of different categories in the source domain. The specific steps are:

[0090] Step 801: In order to obtain the prototype of each category in the source domain, use the correct label of the source domain Extract the features of the foreground area from the second fully connected layer of the region proposal layer, and calculate the category prototype of the kth category for the source domain image The method is as follows:

[0091]

[0092] In the above formula (11), F(r) represents the feature of the foreground region r, Represents the image of category k in the source domain The number of targets in

[0093] Step 802: For the target domain image Use the image to get the pseudo label through the detection head And the pseudo label obtained by the detection head of its texture enhanced image Select pseudo labels and pseudo labels The prediction results with confidence greater than 0.5 are used as joint pseudo labels y uni , and extract the joint pseudo-label y uni The features of the corresponding foreground area, similarly, 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 feature of the foreground region r, Represents the joint pseudo label y of category k in the target domain uni The number of instances in ;

[0096] Step 803: The calculation of the center of the category prototype in the above steps 801 and 802 is performed within a training batch. In order to ensure the stability and consistency of the detection model, the existing category prototype needs to be updated when the next training iteration starts. This process is achieved by:

[0097]

[0098] In the above formula (13), the parameter α∈(0,1) is used to control the proportion of prototype update. represents the prototype of the kth category at the i-th iteration, Represents the prototype of the kth category at the i-1th iteration;

[0099] 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 domain and the target domain, and to maximize the Euclidean distance between prototypes of different categories in the source domain, so as to promote the feature representation of the same category in the source domain and the target domain to be more similar, and at the same time, the feature representation between different categories has a higher degree of distinction. The loss function of the defect category prototype adversarial module is expressed as:

[0100]

[0101] In the above formula (14), represents the category prototype of the kth category in the source domain at the i-th iteration, represents the category prototype of the kth category in the target domain at the i-th iteration, ||·|| 2 Represents the calculation of Euclidean distance. Through the above mechanism, the defect category prototype adversarial module can effectively align the feature representations between the source domain and the target domain, and enhance the detection ability of the model in the target domain.

[0102] Furthermore, in step 9, the overall target loss of the model is calculated The specific steps are:

[0103]

[0104] In the above formula (15), represents the target detection loss of the source domain image, represents the defect object detection loss of the source domain cloth-enhanced image, represents the domain adversarial loss, represents the loss of the defect category prototype adversarial module, and the hyperparameters γ and η are used to balance different loss terms.

[0105] Furthermore, in step 11, during the test reasoning phase of the model, the test image is input into the trained cross-domain cloth defect detection model to calculate and output the defect area. The specific steps are as follows:

[0106] Step 1101: The cloth defect image x m Input the cloth image texture enhancement module to enhance the texture features of the image and obtain a texture enhanced image

[0107] Step 1102: The original target domain cloth defect image x m And the texture enhanced image Input to the domain feature extractor V A and enhanced domain feature extractor V B Perform feature extraction;

[0108] Step 1103: V A and V B The source domain image features output by the fifth convolutional block of the network are concatenated with the texture enhanced image features to obtain the joint features. And input the texture feature joint attention module;

[0109] Step 1104: Send the texture feature and the feature output by the attention module to the region proposal layer for region proposal, and finally perform defect target detection through the detection head and output the detection result.

[0110] Compared with the existing similar methods, the method of the present invention has the following advantages:

[0111] 1. The method described in the present invention solves the problem of performance degradation of traditional target detection models when facing distribution shift by integrating the detailed texture knowledge of source domain and target domain images. The innovative cross-domain detection framework design enables the model to better adapt to new data distribution and improves the detection accuracy and generalization ability.

[0112] 2. The cloth image texture enhancement module used in the method of the present invention utilizes fast Fourier transform and high-pass filtering technology to selectively enhance the high-frequency texture information in the fabric image, which not only improves the detection model's ability to recognize complex texture features, but also removes low-frequency components, allowing the model to focus more on high-frequency details, thereby improving detection accuracy.

[0113] 3. Advanced joint attention mechanism: The method described in the present invention introduces a texture feature joint attention module, which integrates the original image features and texture enhanced image features through the self-attention mechanism, emphasizes the key areas and internal connections in the image, and enables the detection model to adaptively adjust the weights of different areas and channels, enhances the attention to key textures and defect areas, and improves the model's defect detection capabilities in complex backgrounds.

[0114] 4. The defect category prototype adversarial module used in the method described in the present invention realizes the robust alignment of source domain and target domain features by generating category prototype centers and adjusting feature distances. It reduces the distribution difference between the source domain and the target domain by bringing 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 of the present invention performs effective training and detection without labeling the target domain samples. By utilizing pseudo-labels and self-supervised learning techniques, the detection model can learn the characteristics of the target domain without the assistance of manual labeling, significantly reducing the cost and complexity of data preparation, and improving the accuracy of detection, so that the detection model can quickly adapt to new application scenarios, and has significant industrial application value. BRIEF DESCRIPTION OF THE DRAWINGS

[0116] Figure 1 The figure is a schematic diagram of the process of the method of the present invention.

[0117] Figure 2 Schematic diagram of the framework of the training phase of the method of the present invention.

[0118] Figure 3 A schematic diagram of the framework of the test reasoning phase of the method of the present invention. DETAILED DESCRIPTION

[0119] In order to make the purpose, technical solution and advantages of the method described in the present invention clearer, the specific embodiment of the detection model detection method described in the present invention is 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 adopts fast Fourier transform to convert the input image from the spatial domain to the frequency domain, and uses filter technology to highlight the high-frequency texture information in the image; the texture feature joint attention module deeply learns the key areas and structural information in the image, integrates the original image features and the features processed by texture enhancement through the self-attention mechanism, realizes adaptive weight adjustment of the key areas of the image, and enhances the detection capability of complex textures and defective areas; the defect category prototype confrontation module creates category prototypes of the source domain and the target domain, adopts the strategy of feature distance pulling closer and farther, 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] Example 2

[0123] The detection method, such as Figure 1 As shown, the following steps are included:

[0124] Step 1: Collect source domain cloth defect image dataset D S And the target domain cloth defect image dataset D T , domain feature extractor V A and enhanced domain feature extractor V B Initialize parameters respectively;

[0125] Step 2: Randomly sample a source domain cloth image sample and a target domain cloth image sample Use the cloth image texture enhancement module to respectively And target domain cloth image samples Enhance the texture information and obtain the enhanced source domain image and the target domain image Perform texture enhancement on source and target domain images.

[0126] Step 3: Source domain cloth image and the target domain image After the domain feature extractor V A Feature extraction and enhanced source domain image and the target domain image Via domain-enhanced feature extractor V B Perform feature extraction;

[0127] Step 4: Domain feature extractor V A and domain enhanced feature extractor V BThe source domain image and its texture enhanced image features output by the 3rd, 4th, and 5th convolutional blocks are concatenated, and the concatenated 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;

[0128] Step 5: Use the domain feature extractor V A and enhanced domain feature extractor V B The joint feature of the image feature output by the 5th convolutional block and its texture enhanced image feature Input to the texture feature joint attention module to learn the connection between the original image and the texture enhanced image, strengthen the model's attention to texture details, and perform joint attention learning on the input image and its texture enhanced image;

[0129] Step 6, calculate the object detection loss of the source domain cloth image;

[0130] Step 7, calculating the defect object detection loss of the source domain cloth enhanced image;

[0131] Step 8, using the source domain image label to calculate the prototype of each category in the source domain, using the pseudo label of the target domain image and the pseudo label of its texture enhanced image to calculate the prototype of each category of the target domain data, and the loss of training calculation is performed by minimizing the distance between the prototypes of the same category in the source domain and the target domain and maximizing the distance between the prototypes of different categories in the source domain;

[0132] In step 9, the overall target loss of the model is calculated

[0133] Step 10. Repeat steps 2 to 9 until the maximum number of iterations I is reached or the model parameters converge;

[0134] Step 11, such as Figure 3 As shown, in the test reasoning stage of the model, the test image is input into the trained cross-domain cloth defect detection model to calculate and output the defect area.

[0135] As an optional specific embodiment, the specific steps of step 1 are:

[0136] Step 101: Use a camera on an actual cloth production textile machine to capture cloth defect images in the source domain and the target domain, ensuring that each image can clearly show the appearance of the cloth. The source domain is represented as The unlabeled target domain is represented as in: represents the source domain cloth image, is the target domain image;

[0137] Step 102: marking defective areas of the source domain image. Represents the source domain image The corresponding label information, including the bounding box coordinates and categories

[0138] Step 103: Set hyperparameters α, β, γ, η and the maximum number of iterations I, and use the weight parameters pre-trained on ImageNet to initialize the domain feature extractor V. A and enhanced domain feature extractor V B The weight of .

[0139] As an optional specific embodiment, the specific steps of step 2 are:

[0140] Step 201: Randomly sample a source domain image and the target domain image And input the cloth image texture enhancement module, for the input source domain image in 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:

[0141]

[0142] In the above formula (1), j 2 =-1 is the imaginary unit, Represents the input source domain image, H represents the height of the input image, W represents the width of the input image, and exp represents the exponential function. The Fourier transform decomposes the image into a combination of different frequency components, including amplitude and phase information. The amplitude represents the strength of the signal, while the phase represents the location information of the signal;

[0143] Step 202: Introduce two functions F respectively a and F p To represent the amplitude and phase components of the input image after Fourier transformation:

[0144]

[0145] In the above formula (2), is the frequency domain representation of the input image, |·| represents taking the modulus of the Fourier transform result of each pixel, and arg() represents taking the phase of the Fourier transform result of each pixel;

[0146] Step 203: In order to perform high-pass filtering in the frequency domain, a mask function M is defined. β :

[0147]

[0148] In the above formula (3), M β (h,w) represents the value of the point on the mask with a height of h and a width of w. Here, the center of the spectrum is taken as the center point (0,0). β∈(0,1) is a parameter that controls the size of the center area of ​​the mask. Using this mask, the high-frequency components of the image are retained and the low-frequency components are removed to enhance the texture.

[0149] Step 204: The source domain image The low-frequency part of the Fourier transformed amplitude information is set to zero, forming a new frequency domain representation F shift :

[0150]

[0151] In the above formula (4), M β represents the mask function, Represents the amplitude of the input image after Fourier transformation.

[0152] Step 205: Convert 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 the low-frequency part of the amplitude information is set to zero;

[0155] Step 206: For an input image from the target domain The corresponding conversion image can also be obtained The images processed in this way have their high-frequency texture information significantly enhanced, 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.

[0156] As an optional specific embodiment, the specific steps of step 3 are:

[0157] Step 301: Through feature extractor V A Input images of source and target domains and Perform feature extraction, feature extractor V A It contains 5 convolution blocks, each of which consists of two convolution layers. The ReLU activation function is used to introduce nonlinearity, so that the network can learn more complex feature representations. The output of the convolution layer is then passed to the next convolution layer in the same convolution block, or to the maximum pooling layer after the last convolution layer. and After feature extraction, the output features of the 3rd, 4th, and 5th convolutional blocks are retained, respectively, and are expressed as and

[0158] Step 302: Through feature extractor V B Texture-enhanced images for source and target domains and For feature extraction, the output features of the 3rd, 4th, and 5th convolutional blocks are also retained, which are represented as and

[0159] As an optional specific embodiment, the specific steps of step 4 are:

[0160] Step 401: First, the source domain and target domain image features are fused. A and V B The source domain image features output by the third convolutional block and its texture enhanced image features After splicing, the features after splicing are expressed as Similarly, the concatenated features of the 4th and 5th convolutional blocks are expressed as

[0161] Step 402: V A and V B The output target domain image features and its texture enhanced image features are spliced, and the spliced ​​features are expressed as

[0162] Step 403: Calculate the domain adversarial loss, expressed as:

[0163]

[0164] In the above formula (6), Where L c is the cross entropy loss function, represents the concatenated features of the mth convolutional block, where m∈{3,4,5}, represents the feature channel of the feature at (u,v), θ m is the mth domain classifier parameter corresponding to the concatenated feature, d i is the domain label of the current sample, the source domain is marked as 1, the target domain is marked as 0, and w m It is the parameter of the backbone network corresponding to the current splicing feature.

[0165] As an optional specific embodiment, the specific steps of step 5 are:

[0166] Step 501: VA and V B The source domain image features and its texture enhanced image features output by the 5th convolutional block of the network are concatenated, and the resulting joint features are 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 concatenated with the texture-enhanced image features, and the resulting joint features are defined as

[0168] Step 503: Splice features Input into the texture feature joint attention module, first use an independent 1×1 convolution operation to map the input features to query (Q), key (K) and value (V) representations, where Q is the input vector used to calculate the attention score, K is used to calculate the similarity with the query, and the similarity matrix is ​​obtained by calculating the similarity of Q and K at each position. V is the actual input content. When the similarity calculation of Q and K is completed, V will be weighted and merged according to the similarity. The self-attention mechanism is used here to generate feature representations after the self-attention operation, so that the network can dynamically adjust the features according to the correlation between different positions to better capture the complex texture and detail information in the image. To ensure that the generated feature size can meet the input requirements of the subsequent detection head, a 1×1 convolution is added to further reduce the dimension of these features and splice the features. After the texture feature joint attention module, the output features are obtained respectively.

[0169] As an optional specific embodiment, the specific steps of step 6 are:

[0170] Step 601: for the input source domain cloth image Calculate its classification loss

[0171]

[0172] In the above formula (7), N anchors Display pictures The total number of predicted targets, i is the index of the predicted target, p = (p0, ..., p K ) represents the prediction result of the model for the i-th prediction target on K categories, u=(u0,…,u K ) represents the label category. If the target is the kth category, then u k =1, other values ​​are 0, L cls represents the logarithmic loss between the labeled category and the predicted category. All the labeled categories except the correct category are 0, then Lcls (p,u) = -logp;

[0173] Step 602: for the input source domain cloth image Calculate its regression loss

[0174]

[0175] In the above formula (8), N anchors Display pictures The total number of predicted targets, i is the index of the predicted target, t = (t x ,t y ,t W ,t h ) represents the coordinates of the center point of the i-th predicted target regression box (t x ,t y ), width t W and height t h The prediction result, v = (v x ,v y ,v W ,v h ) indicates a label box, L loc Represents the logarithmic loss between the annotation box and the prediction box:

[0176]

[0177] In the above formula (9), {x, y, w, h} represents the index of the regression box, t = (t x ,t y ,t W ,t h ) represents the coordinates of the center point of the i-th predicted target regression box (t x ,t y ), width t W and height t h The prediction result, v = (v x ,v y ,v W ,v h ) represents the label box, L1 represents the absolute difference between two values;

[0178] Step 603: Calculate the input source domain cloth image The target detection loss is:

[0179]

[0180] In the above formula (10), Represents the input source domain cloth image The classification loss is Represents the input source domain cloth image The regression loss.

[0181] As an optional specific embodiment, the specific steps of step 7 are:

[0182] Step 701: Similarly, according to formula (7), the input source domain cloth enhancement image is calculated The classification loss

[0183] Step 702: Similarly, according to formula (8), the input source domain cloth enhancement image is calculated: The regression loss

[0184] Step 703: Similarly, according to formula (9), the input source domain cloth enhancement image is calculated: The target detection loss

[0185] As an optional specific embodiment, the specific steps of step 8 are:

[0186] Step 801: In order to obtain the prototype of each category in the source domain, use the correct label of the source domain Extract the features of the foreground area from the second fully connected layer of the region proposal layer, and calculate the category prototype of the kth category for the source domain image The method is as follows:

[0187]

[0188] In the above formula (11), F(r) represents the feature of the foreground region r, Represents the image of category k in the source domain The number of targets in

[0189] Step 802: For the target domain image Use the image to get the pseudo label through the detection head And the pseudo label obtained by the detection head of its texture enhanced image Select pseudo labels and pseudo labels The prediction results with confidence greater than 0.5 are used as joint pseudo labels y uni , and extract the joint pseudo-label y uni The features of the corresponding foreground area, similarly, the category prototype of each category k in the target domain The calculation is as follows:

[0190]

[0191] In the above formula (12), F(r) represents the feature of the foreground region r, Represents the joint pseudo label y of category k in the target domain uni The number of instances in ;

[0192] Step 803: The calculation of the center of the category prototype in the above steps 801 and 802 is performed within a training batch. In order to ensure the stability and consistency of the detection model, the existing category prototype needs to be updated when the next training iteration starts. This process is achieved by:

[0193]

[0194] In the above formula (13), the parameter α∈(0,1) is used to control the proportion of prototype update. represents the prototype of the kth category at the i-th iteration, Represents the prototype of the kth category at the i-1th iteration;

[0195] 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 domain and the target domain, and to maximize the Euclidean distance between prototypes of different categories in the source domain, so as to promote the feature representation of the same category in the source domain and the target domain to be more similar, and at the same time, the feature representation between different categories has a higher degree of distinction. The loss function of the defect category prototype adversarial module is expressed as:

[0196]

[0197] In the above formula (14), represents the category prototype of the kth category in the source domain at the i-th iteration, represents the category prototype of the kth category in the target domain at the i-th iteration, ||·|| 2 Represents the calculation of Euclidean distance. Through the above mechanism, the defect category prototype adversarial module can effectively align the feature representations between the source domain and the target domain, and enhance the detection ability of the model in the target domain.

[0198] As an optional specific embodiment, step 9 specifically comprises the following steps:

[0199]

[0200] In the above formula (15), represents the target detection loss of the source domain image, represents the defect object detection loss of the source domain cloth-enhanced image, represents the domain adversarial loss, represents the loss of the defect category prototype adversarial module, and the hyperparameters γ and η are used to balance different loss terms.

[0201] As an optional specific embodiment, Figure 3 As shown, the specific steps of step 11 are:

[0202] Step 1101: The cloth defect image x m Input the cloth image texture enhancement module to enhance the texture features of the image and obtain a texture enhanced image

[0203] Step 1102: The original target domain cloth defect image x m And the texture enhanced image Input to the domain feature extractor V A and enhanced domain feature extractor V B Perform feature extraction;

[0204] Step 1103: V A and V B The source domain image features output by the fifth convolutional block of the network are concatenated with the texture enhanced image features to obtain the joint features. And input the texture feature joint attention module;

[0205] Step 1104: Send the texture feature and the feature output by the attention module to the region proposal layer for region proposal, and finally perform defect target detection through the detection head and output the detection result.

[0206] In the implementation process of the model training of the present invention, two images are input for each training batch, one from the source domain dataset and the other from the target domain dataset. During the training process, the stochastic gradient descent (SGD) method with a momentum of 0.9 and a weight decay factor of 0.0005 is used to update the model parameters. The learning rate is initially set to 0.001, which is used in the first 30,000 iterations of model training, and then reduced to 0.0001, and the iterative training is continued for 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 detection method of the present invention in the cloth defect target detection task, a test was conducted on the cloth defect image data actually produced, and the mean average precision (mAP) was used to objectively evaluate the performance of the model. Specifically:

[0208] True Positive (TP): refers to the number of samples that the model correctly predicts as positive. For example, in defect detection, if the model detects a defect and there is indeed a defect, 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 does not detect actual defects, 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 defect detection, if the model mistakenly identifies a flawless part as defective, this 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 in TN.

[0212] The true positive rate TPR and the false positive rate FPR are as follows:

[0213]

[0214] Precision Precision and recall 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 the AP values ​​of all categories are averaged to get mAP. mAP is a comprehensive indicator that reflects the overall performance of the model on different categories. mAP is calculated under different confidence thresholds. For example, mAP@0.5 means mAP when the confidence threshold is 0.5.

[0219] The detection results of cross-domain cloth broken warp and weft target detection in an actual production environment by the detection method of the present invention are achieved. By performing detection between multiple fabric types, including migration detection from plain to twill, twill to plain, and satin to plain, the detection method of the present invention can accurately identify and locate various fabric defects, demonstrating excellent generalization ability and adaptability. Whether it is subtle texture changes or obvious defects, the detection method of the present invention can effectively capture them, ensuring the high accuracy of the detection results. At the same time, the detection method of the present invention can adaptively adjust the focus on different texture features, thereby achieving stable detection performance in cross-domain scenarios.

[0220] The present invention is not limited by the above embodiments. The above embodiments and descriptions are only for explaining the principle of the present invention. Without departing from the spirit and scope of the present invention, the present invention may be subject to various changes and improvements, which are within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the appended claims.

Claims

1. A warp and weft break detection model based on cross-cloth texture feature enhancement, the detection model includes: 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 uses fast Fourier transform to convert the input image from the spatial domain to the frequency domain, and uses filter technology to highlight the high-frequency texture information in the image; the texture feature joint attention module deeply learns the key areas and structural information in the image, and integrates the original image features and the features processed by texture enhancement through the self-attention mechanism to achieve adaptive weight adjustment of the key areas of the image, and enhance the detection ability of complex textures and defective areas; the defect category prototype adversarial module creates category prototypes in the source domain and the target domain, and adopts the strategy of feature distance pulling closer and farther to further align the feature distribution of the source domain and the target domain, thereby improving the generalization and adaptability of the model in the target domain.

2. A warp and weft break detection method based on cross-cloth texture feature enhancement, the detection method comprising: Step 1. Collect source domain cloth defect image dataset D S And the target domain cloth defect image dataset D T , domain feature extractor V A and enhanced domain feature extractor V B Initialize parameters respectively; Step 2. Randomly sample a source domain cloth image sample and a target domain cloth image sample Use the cloth image texture enhancement module to respectively And target domain cloth image samples Enhance the texture information and obtain the enhanced source domain image and the target domain image Perform texture enhancement on source and target domain images; Step 3. Source domain cloth image and the target domain image After the domain feature extractor V A Feature extraction and enhanced source domain image and the target domain image Via domain-enhanced feature extractor V B Perform feature extraction; Step 4. Use the domain feature extractor V A and domain enhanced feature extractor V B The source domain image and its texture enhanced image features output by the 3rd, 4th, and 5th convolutional blocks are concatenated, and the concatenated 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; Step 5. Use the domain feature extractor V A and enhanced domain feature extractor V B The joint feature of the image feature output by the 5th convolutional block and its texture enhanced image feature The input is sent to 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. Step 6. Calculate the object detection loss of the source domain cloth image; Step 7. Calculate the defect object detection loss of the source domain cloth enhanced image; Step 8. Use the source domain image label to calculate the prototype of each category in the source domain, use the pseudo label of the target domain image and the pseudo label of its texture enhanced image to calculate the prototype of each category of the target domain data, and train the defect category prototype adversarial module by minimizing the distance between the prototypes of the same category in the source domain and the target domain and maximizing the distance between the prototypes of different categories in the source domain; Step 9. Calculate the overall objective loss L of the model TKG , and back-propagate to update the model parameters; Step 10. Repeat steps 2 to 9 until the maximum number of iterations I is reached or the model parameters converge; Step 11. In the test reasoning phase of the model, the test image is input into the trained cross-domain cloth defect detection model to calculate and output the defect area.

3. According to the detection method of claim 2, in step 1, a source domain cloth defect image dataset D is collected S And the target domain cloth defect image dataset D T , domain feature extractor V A and enhanced domain feature extractor V B Initialize the parameters respectively. The specific steps are as follows: Step 101: Use a camera on an actual cloth production textile machine to capture cloth defect images in the source domain and the target domain, ensuring that each image can clearly show the appearance of the cloth. The source domain is represented as The unlabeled target domain is represented as in: represents the source domain cloth image, is the target domain image; Step 102: marking defective areas of the source domain image. Represents the source domain image The corresponding label information, including the bounding box coordinates and categories Step 103: Set hyperparameters α, β, γ, η and the maximum number of iterations I, and use the weight parameters pre-trained on ImageNet to initialize the domain feature extractor V. A and enhanced domain feature extractor V B The weight of .

4. According to the detection method of claim 2, in step 2, a source domain cloth image sample is randomly sampled and a target domain cloth image sample Use the cloth image texture enhancement module to respectively And target domain cloth image samples Enhance the texture information and obtain the enhanced source domain image and the target domain image Texture enhancement is performed on source and target domain images. The specific steps are as follows: Step 201: Randomly sample a source domain image and the target domain image And input the cloth image texture enhancement module, for the input source domain image in 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: In the above formula (1), j 2 =-1 is the imaginary unit, Represents the input source domain image, H represents the height of the input image, W represents the width of the input image, and exp represents the exponential function. The Fourier transform decomposes the image into a combination of different frequency components, including amplitude and phase information. The amplitude represents the strength of the signal, while the phase represents the location information of the signal; Step 202: Introduce two functions F respectively a and F p To represent the amplitude and phase components of the input image after Fourier transformation: In the above formula (2), is the frequency domain representation of the input image, |·| represents taking the modulus of the Fourier transform result of each pixel, and arg() represents taking the phase of the Fourier transform result of each pixel; Step 203: In order to perform high-pass filtering in the frequency domain, a mask function M is defined. β : In the above formula (3), M β (h,w) represents the value of the point on the mask with a height of h and a width of w. Here, the center of the spectrum is taken as the center point (0,0). β∈(0,1) is a parameter that controls the size of the center area of ​​the mask. Using this mask, the high-frequency components of the image are retained and the low-frequency components are removed to enhance the texture. Step 204: The source domain image The low-frequency part of the Fourier transformed amplitude information is set to zero, forming a new frequency domain representation F shift : In the above formula (4), M β represents the mask function, Represents the amplitude of the input image after Fourier transformation; Step 205: Convert the modified frequency domain image back to the spatial domain by inverse Fourier transform: In the above formula (5), FFT -1 represents the inverse Fourier transform, F shift represents the frequency domain representation of the input image after the low-frequency part of the amplitude information is set to zero; Step 206: For an input image from the target domain The corresponding conversion image can also be obtained The images processed in this way have their high-frequency texture information significantly enhanced, 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 cloth image and the target domain image After the domain feature extractor V A Feature extraction and enhanced source domain image and the target domain image Via domain-enhanced feature extractor V B Perform feature extraction. The specific steps are: Step 301: Through feature extractor V A Input images of source and target domains and Perform feature extraction, feature extractor V A It contains 5 convolution blocks, each of which consists of two convolution layers. The ReLU activation function is used to introduce nonlinearity, so that the network can learn more complex feature representations. The output of the convolution layer is then passed to the next convolution layer in the same convolution block, or to the maximum pooling layer after the last convolution layer. and After feature extraction, the output features of the 3rd, 4th, and 5th convolutional blocks are retained, respectively, and are expressed as and Step 302: Through feature extractor V B Texture-enhanced images for source and target domains and For feature extraction, the output features of the 3rd, 4th, and 5th convolutional blocks are also retained, which are represented as and 6. According to the detection method of claim 2, in step 4, the domain feature extractor V A and domain enhanced feature extractor V B The source domain image and its texture enhanced image features output by the 3rd, 4th, and 5th convolutional blocks are spliced, 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. The specific steps are as follows: Step 401: First, the source domain and target domain image features are fused. A and V B The source domain image features output by the third convolutional block and its texture enhanced image features After splicing, the features after splicing are expressed as Similarly, the concatenated features of the 4th and 5th convolutional blocks are expressed as Step 402: V A and V B The output target domain image features and its texture enhanced image features are spliced, and the spliced ​​features are expressed as Step 403: Calculate the domain adversarial loss, expressed as: In the above formula (6), Where L c is the cross entropy loss function, represents the concatenated features of the mth convolutional block, where m∈{3,4,5}, represents the feature channel of the feature at (u,v), θ m is the mth domain classifier parameter corresponding to the concatenated feature, d i is the domain label of the current sample, the source domain is marked as 1, the target domain is marked as 0, and w m It is the parameter 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 V A and enhanced domain feature extractor V B The joint feature of the image feature output by the 5th convolutional block and its texture enhanced image feature Input to the texture feature joint attention module to learn the connection between the original image and the texture enhanced image, and strengthen the model's attention to texture details. The input image and its texture enhanced image are jointly learned with attention. The specific steps are: Step 501: V A and V B The source domain image features and its texture enhanced image features output by the 5th convolutional block of the network are concatenated, and the resulting joint features are defined as Step 502: V A and V B The target domain image features output by the fifth convolutional block of the network are concatenated with the texture-enhanced image features, and the resulting joint features are defined as Step 503: Splice features The input is input into the texture feature joint attention module, and an independent 1×1 convolution operation is used to map the input features to query (Q), key (K) and value (V) representations, where Q is used to calculate the input vector of the attention score, and K is used to calculate the similarity with the query. By calculating the similarity of Q and K at each position, the similarity matrix is ​​obtained. V is the actual input content. When the similarity calculation of Q and K is completed, V will be weighted and merged according to the similarity. The self-attention mechanism is used here to generate feature representations after the self-attention operation, so that the network can dynamically adjust the features according to the correlation between different positions to better capture the complex texture and detail information in the image. To ensure that the generated feature size can meet the input requirements of the subsequent detection head, a 1×1 convolution is added to further reduce the dimension of these features and splice the features. After 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 cloth image is calculated, and the specific steps are: Step 601: for the input source domain cloth image Calculate its classification loss In the above formula (7), N anchors Display pictures The total number of predicted targets, i is the index of the predicted target, p = (p0, ..., p K ) represents the prediction result of the model for the i-th prediction target on K categories, u=(u0,…,u K ) represents the label category. If the target is the kth category, then u k =1, other values ​​are 0, L cls represents the logarithmic loss between the labeled category and the predicted category. All the labeled categories except the correct category are 0, then L cls (p,u) = -logp; Step 602: for the input source domain cloth image Calculate its regression loss In the above formula (8), N anchors Display pictures The total number of predicted targets, i is the index of the predicted target, t = (t x ,t y ,t W ,t h ) represents the coordinates of the center point of the i-th predicted target regression box (t x ,t y ), width t W and height t h The prediction result, v = (v x ,v y ,v W ,v h ) indicates a label box, L loc Represents the logarithmic loss between the annotation box and the prediction box: L loc (t,v)=Σ i∈{x,y,w,h} L1(t i -v i )......(9), In the above formula (9), {x, y, w, h} represents the index of the regression box, t = (t x ,t y ,t W ,t h ) represents the coordinates of the center point of the i-th predicted target regression box (t x ,t y ), width t W and height t h The prediction result, v = v x ,v y ,v W ,v h ) represents the label box, L1 represents the absolute difference between two values; Step 603: Calculate the input source domain cloth image The target detection loss is: In the above formula (10), Represents the input source domain cloth picture The classification loss is Represents the input source domain cloth picture The regression loss.

9. According to the detection method of claim 2, in step 7, the defect target detection loss of the source domain cloth enhanced image is calculated, and the specific steps are: Step 701: Similarly, according to formula (7), the input source domain cloth enhancement image is calculated The classification loss Step 702: Similarly, according to formula (8), the input source domain cloth enhancement image is calculated: The regression loss Step 703: Similarly, according to formula (9), the input source domain cloth enhancement image is calculated: The 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, the prototype of each category of the target domain data is calculated using the pseudo label of the target domain image and the pseudo label of its texture enhanced image, and the loss calculation of the defect category prototype adversarial module is performed by minimizing the distance between the prototypes of the same category in the source domain and the target domain and maximizing the distance between the prototypes of different categories in the source domain, and the specific steps are: Step 801: In order to obtain the prototype of each category in the source domain, use the correct label of the source domain Extract the features of the foreground area from the second fully connected layer of the region proposal layer, and calculate the category prototype of the kth category for the source domain image The method is as follows: In the above formula (11), F(r) represents the feature of the foreground region r, Represents the image of category k in the source domain The number of targets in Step 802: For the target domain image Use the image to get the pseudo label from the detection head And the pseudo label obtained by the detection head of its texture enhanced image Select pseudo labels and pseudo labels The prediction results with confidence greater than 0.5 are used as joint pseudo labels y uni , and extract the joint pseudo-label y uni The features of the corresponding foreground area, similarly, the category prototype of each category k in the target domain The calculation is as follows: In the above formula (12), F(r) represents the feature of the foreground region r, Represents the joint pseudo label y of category k in the target domain uni The number of instances in ; Step 803: The calculation of the center of the category prototype in the above steps 801 and 802 is performed within a training batch. In order to ensure the stability and consistency of the detection model, the existing category prototype needs to be updated when the next training iteration starts. This process is achieved by: In the above formula (13), the parameter α∈(0,1) is used to control the proportion of prototype update. represents the prototype of the kth category at the i-th iteration, Represents the prototype of the kth category at the i-1th iteration; 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 domain and the target domain, and to maximize the Euclidean distance between prototypes of different categories in the source domain, so as to promote the feature representation of the same category in the source domain and the target domain to be more similar, and at the same time, the feature representation between different categories has a higher degree of distinction. The loss function of the defect category prototype adversarial module is expressed as: In the above formula (14), represents the category prototype of the kth category in the source domain at the i-th iteration, represents the category prototype of the kth category in the target domain at the i-th iteration, ||·|| 2 Represents the calculation of Euclidean distance. Through the above mechanism, the defect category 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; In step 9, the overall target loss of the model is calculated The specific steps are: In the above formula (15), represents the target detection loss of the source domain image, represents the defect object detection loss of the source domain cloth-enhanced image, represents the domain adversarial loss, represents the loss of the defect category prototype adversarial module, and the hyperparameters γ and η are used to balance different loss terms; In step 11, during the test reasoning phase of the model, the test image is input into the trained cross-domain cloth defect detection model to calculate and output the defect area. The specific steps are as follows: Step 1101: The cloth defect image x m Input the cloth image texture enhancement module to enhance the texture features of the image and obtain a texture enhanced image Step 1102: The original target domain cloth defect image x m And the texture enhanced image Input to the domain feature extractor V A and enhanced domain feature extractor V B Perform feature extraction; Step 1103: V A and V B The source domain image features output by the fifth convolutional block of the network are concatenated with the texture enhanced image features to obtain the joint features. And input the texture feature joint attention module; Step 1104: Send the texture feature and the feature output by the attention module to the region proposal layer for region proposal, and finally perform defect target detection through the detection head and output the detection result.

Citation Information

Patent Citations

  • Method for detecting image anomaly by aligning multi-spectrum cross-domain feature in automatic driving

    CN113792609A

  • Cloth flaw identification method and model training method

    CN113807434A

  • Cross-cloth flaw accurate detection method based on visual domain adaptive learning

    CN115393265A

  • Cross-domain small sample defect target detection method

    CN115587969A

  • Fabric defect detection method based on improved YOLOv7 model

    CN117372332A

Cited By

  • Real-time rendering optimization method and system in meta universe scene building engine

    CN119941956A

  • Garment processing raw material cloth defect intelligent sorting system and method based on machine vision

    CN120564004A

  • Cloth surface flaw detection method and device based on texture perception and anomaly detection

    CN121169883A

  • Method and device for detecting surface defects of cloth based on texture perception and anomaly detection

    CN121169883B