Method for detecting fine-grained defects across fabric in blurred lighting scenarios
By constructing a basic module for fine-grained defect detection, a low-brightness blurred illumination modulation module, and a deviation-aware false detection and false negative detection suppression module, combined with a self-attention mechanism and a decoder, the generalization problem of fabric defect detection under low-brightness blurred illumination and multiple fabric types was solved, achieving efficient and accurate defect detection and reducing the data annotation cost of new production lines.
Patent Information
- Application Number
- CN202211575391.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-08
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2042-12-08
AI Technical Summary
Existing fabric defect detection methods are difficult to generalize in low-brightness, blurry lighting conditions, and have poor detection performance for different fabric types. Furthermore, they require retraining on new production lines, resulting in high costs.
A cross-fabric fine-grained defect detection method is adopted. By constructing a basic module for fine-grained defect detection, a low-brightness blurry illumination modulation module, and a deviation-aware false detection and false negative detection suppression module, combined with a self-attention mechanism and a decoder, the method generalizes the model in the target domain using source domain knowledge and optimizes the model using pseudo-label information.
It enables fine-grained defect detection of various fabric types under low-brightness and blurred lighting conditions, improving detection accuracy, reducing false positives and false negatives, and lowering data labeling costs for new production lines.
Smart Images

Figure CN115841473B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of fabric defect detection technology, specifically relating to a method for detecting fine-grained defects across fabrics under blurred lighting conditions. Background Technology
[0002] Fabric, as a raw material for everyday items such as clothing and bags, plays a vital role in people's daily lives. To ensure and improve the quality of life for the general public, rigorous inspection of fabric defects is an indispensable part of the entire fabric production process. Defective fabric entering the market reduces the user experience and hinders sales. With the increasing scale of industrial manufacturing, fabric production lines need to operate at extremely high efficiency, making quality control increasingly difficult. Currently, most industrial methods for fabric defect detection rely on visual inspection and localization. This method requires inspectors to have high professional skills and expertise, and the judgment of defect types is easily influenced by subjective evaluation standards, resulting in limited accuracy and difficulty in controlling labor costs. These manual inspection methods are increasingly unable to meet the efficiency requirements of modern fabric production lines. Therefore, vision-based methods have gradually attracted attention in the industry. Some image processing-based methods have been proposed to alleviate the problems of low accuracy and time-consuming nature of manual inspection, attempting to eliminate the adverse effects of subjective factors on the inspection results.
[0003] While existing methods incorporate visual techniques to alleviate the problems associated with manual visual inspection and provide more accurate and objective results, they suffer from several limitations. Firstly, most are limited to detecting fabric defects in single scenes or under good lighting conditions, failing to consider the differences in lighting environments and fabric textures across different fabric defect detection lines. This makes it difficult to detect defects in low-brightness, blurry lighting scenarios, and also hinders their generalization to different fabric types. Consequently, while they may achieve good results on closed datasets, their performance in real-world applications is subpar. Specifically, on fabric defect detection production lines, variations in lighting conditions can lead to insufficient light, excessive brightness, uneven brightness, and blurred images. Furthermore, there are significant differences between solid-color fabrics, fabrics with regular patterns, and fabrics with irregular patterns in terms of fabric color and texture. These factors can lead to domain bias, challenging the model's generalization performance on fabric images in these new scenarios. Secondly, previous methods focused on image-level fabric defect detection. These methods have a large prediction granularity, only able to perceive and predict the approximate location of small defect areas. Therefore, they are prone to difficulty in detecting defects when their type, size, and shape change, making their detection results for defects such as long, tight lines across the image and large-scale color differences unstable. Finally, when these methods are applied to new fabric production lines, they inevitably require retraining with the labeled data of the fabrics on the new production line. This drastically increases the cost of deployment to new production lines, hindering widespread adoption. Therefore, in order to generalize fabric defect detection to more complex low-brightness blurred lighting scenarios and more diverse fabric types, and to achieve more fine-grained prediction of defect location and range, it is necessary to design a higher quality and more efficient fine-grained fabric defect detection method. This will help the model maintain good defect detection performance under low-brightness blurred lighting conditions and changes in fabric type, and will also take into account the improvement of data utilization efficiency.
[0004] While some progress has been made in fabric defect detection, these methods heavily rely on image processing and prior knowledge based on low-level vision. For example, they use filtered images to determine defect locations and manually design defect scores to judge whether a defect exists. These methods can only achieve good results for specific datasets and are difficult to perform well in real-world applications with low-brightness and blurred lighting. They also cannot achieve the desired results for defect regions of different shapes and sizes. In addition, while there are some image defect detection methods based on semantic segmentation, their application in fabric defect detection has not yet been explored, making it difficult to achieve higher accuracy and more precise localization.
[0005] For example, Chinese invention patent application number CN202210588414.5 discloses a method and system for detecting composite defects in images based on semantic segmentation, including the following steps: S1. Constructing a semantic segmentation network model; S2. Obtaining a first image set and inputting the first image dataset into the initialized semantic segmentation network model for pre-training; S3. Setting the number of channels in the output layer of the pre-trained semantic segmentation network model according to the required number of defect types to be detected; S4. Obtaining a second image dataset and inputting the second image dataset into the pre-trained semantic segmentation network model for training to obtain a semantic segmentation network model with composite defect detection capability; S5. Inputting the image data to be detected into the semantic segmentation network model with composite defect detection capability to obtain a defect prediction map. This invention solves the problem that existing technologies rely on manually designed defect recognition algorithms and can only detect single defects, and has the characteristics of high efficiency and small error.
[0006] For example, Chinese invention patent application CN201810706689.8 discloses a small object semantic segmentation method combining object detection. The steps are as follows: 1. Construct a DeepLab-Attention semantic segmentation network and train it to obtain an overall semantic segmentation model; 2. Create a small object detection dataset and a small object semantic segmentation dataset; 3. Train a YOLOv2-based small object detection network using the small object detection dataset; 4. Design a small object semantic segmentation network and train it using the small object semantic segmentation dataset to obtain a small object semantic segmentation model; 5. In the testing phase, use the test image as input to both the overall semantic segmentation model and the small object detection network to obtain the segmentation result of the entire image and the bounding boxes of the small objects present in the image, which are then corrected using the small object semantic segmentation model. This invention can significantly reduce the segmentation difficulty of small objects, thereby effectively improving the segmentation performance of small objects.
[0007] For example, Chinese invention patent application CN201811634761.7 discloses a method for semantic segmentation-assisted object detection, including the following steps: selecting a backbone network and setting parameters: semantic segmentation and object detection share the same backbone network; designing a spatial information feedback module: fusing the output features of the last two modules Block4' and Block5' of the semantic segmentation branch with the output features of Block4 and Block5 of the object detection branch, and feeding back the output features of the semantic segmentation branch to the object detection branch to enhance the features of object detection; designing a global attention mechanism module. Based on the selected backbone network and the designed spatial information feedback module and global attention mechanism module, the structure of semantic segmentation-assisted object detection is designed.
[0008] The aforementioned invention patent application has the following shortcomings:
[0009] The above-mentioned technical solutions are all aimed at the small-scale problem of target detection in simple scenarios. The data used has a relatively fixed data distribution, making it difficult to have good generalization ability and maintain detection accuracy in more complex fabric patterns and low-brightness blurred lighting scenarios. They do not fully consider the situation where the model will encounter data that is very different from the training data domain in actual application scenarios, which makes these methods have low detection accuracy on complex new data.
[0010] In view of the above-mentioned technical problems in the existing technology, the present invention provides a method for detecting fine-grained defects across fabrics in a blurred lighting scene. Summary of the Invention
[0011] This invention proposes a method for detecting fine-grained defects across fabrics in blurred lighting conditions.
[0012] The present invention adopts the following technical solution:
[0013] A method for detecting fine-grained defects across fabric in blurred lighting conditions includes:
[0014] Step 1: The lightweight fabric imaging module collects a dataset of source domain labeled fabric defect detection images D. s And the target domain unlabeled fabric defect detection image dataset D t Among them, the target domain unlabeled fabric defect detection image dataset D t It was formed by collecting fabric images in low-brightness, blurry lighting scenarios with a brightness of less than 20 nits;
[0015] Step 2: Construct the basic module for fine-grained defect detection and the domain-aware adaptation module;
[0016] Step 3, sample a source domain data X s and a target domain sample data X t As input to the cross-fabric fine-grained defect detection model, the target domain sample data X t Enhanced target domain samples, which are beneficial for perception, are obtained through a low-brightness blur lighting modulation module.
[0017] Step 4, based on the source domain sample data X s Obtain the logical value L for defect prediction on the source domain samples. s Based on the target domain sample data X t and target domain augmentation samples Obtain the logical value L of the target domain defect detection prediction result. t and Based on the logical value L s L t , Obtain the logic value after suppressing the erroneous prediction results.
[0018] Step 5: Train a fine-grained defect detection model across fabrics;
[0019] Step 6: Input the fabric image data of the target domain fabric production line collected in real time into the trained fabric defect detection model for defect detection, and select the prediction result with the highest classification confidence in the model output as the final detection result.
[0020] Furthermore, in step 2, constructing the domain-aware adaptation module includes:
[0021] Create a low-brightness blurred illumination modulation module;
[0022] Create a bias-aware false positive and false negative suppression module.
[0023] Furthermore, step 4 includes:
[0024] Step 41, Source Domain Sample Data X s After passing through the MiT-B5 backbone self-attention network F, multi-layered output feature maps are obtained. These feature maps are then input into the decoder G to obtain the logical values L for defect prediction on the source domain samples. s ; Target domain sample data X t and target domain augmentation samples All features are obtained through the MiT-B5 backbone network F, which generates multi-layer feature maps. These feature maps are then passed through the decoder G to obtain the logical value L of the target domain defect detection prediction result. t and
[0025] Step 42, augment the target domain samples Using the network to generate fake tags As proxy annotation information, it also guides the target domain sample data X. t and target domain augmentation samples Training;
[0026] Step 43, predict the logical value L s L t , The data is fed into the bias-aware false positive and false negative suppression module for adjustment to suppress potential erroneous predictions, resulting in a suppressed logic value.
[0027] Furthermore, step 6 includes:
[0028] Step 61, use the suppressed logic value Calculate the final fabric defect detection prediction results separately. The loss functions for the prediction results are calculated using the ground truth annotations in the source domain and the proxy annotations in the target domain, respectively.
[0029] Step 62: Weight the target domain loss using the target domain confidence level w, and calculate the complete loss. The stochastic gradient descent algorithm is used for backpropagation to update the model parameters and minimize the loss function, thereby achieving reliable knowledge transfer from the source domain to the target domain to improve the generalization and performance of the target domain.
[0030] Step 63: Repeat steps 61-63 to train the model until it converges or reaches the maximum number of iterations.
[0031] Furthermore, in step 1, D s and D t The representations are as shown in equations (1) and (2) respectively:
[0032]
[0033]
[0034] In equations (1) and (2) above, D s D represents a source domain labeled fabric defect detection image dataset. t Unlabeled fabric defect detection image dataset for the target domain. It is an image from the source domain, N s It represents the total number of images in the source domain, with the superscript (i) indicating the i-th image; It is the image of the target domain, N t This is the total number of source domain images. Let H and W represent the height and length of the i-th image in the source and target domains, respectively, where each image has 3 channels. Represents the pixel-by-pixel annotation of the source domain.
[0035] Furthermore, the low-brightness blurry illumination modulation module in step 3 is designed based on the physical model as shown in equation (3):
[0036] A(x)=tr(x)C(x)+(1-tr(x))B……(3),
[0037] In the above formula (3), C(x) is a pixel in the image under low brightness and blurred lighting conditions, tr(x) represents the light transmittance at the pixel under the current lighting scene, B represents the estimate of the global lighting conditions, and A(x) is the enhanced image obtained after removing the influence of lighting conditions.
[0038] The calculation method of tr(x) is as follows (4):
[0039]
[0040] In equation (4) above, avg sat η represents the mean estimate of saturation in an image. tr The weighting coefficients represent the enhancement level, where z∈N(x) represents a selected pixel z in a region near position x, and C t (z) represents the value of the t channel of the image at that point, where g, b, and r represent the green, blue, and red color channels, respectively, and B... t This represents the value of the t-channel after global illumination estimation, and the target domain sample data X. t As C(x) in equation (3), input into the low-brightness blurred illumination modulation module, the resulting enhanced image A(x) is used as
[0041] Furthermore, in step 41, the formula for predicting the logical value in the source domain is expressed as equation (5):
[0042]
[0043] In the above formula (5), L represents the feature map of the i-th layer generated by encoder F from the source domain samples, where k represents the layer number of the encoder output feature map. s The target domain sample data X represents the predicted logical value obtained after the feature map is decoded by the decoder G. t and target domain augmentation samples The corresponding formulas for the predicted logic values are expressed as in equations (6) and (7):
[0044]
[0045]
[0046] In the above formula (6), X represents t The feature map of the i-th layer generated by encoder F, where k represents the layer number of the encoder output feature map, L t This represents the predicted logical value obtained after the feature map is decoded by the decoder G; in the above equation (7), express The feature map of the i-th layer generated by encoder F, where k represents the layer number of the encoder output feature map. This represents the predicted logical value obtained after the feature map is processed by the decoder G.
[0047] Furthermore, in step 42, through Calculate proxy annotation information The formula is expressed as in equation (8):
[0048]
[0049] In equation (8) above, Indicates the enhanced target domain image The corresponding predicted logistic value, σ represents the Softmax activation function. The model represents the The above prediction This represents the pseudo-label obtained by taking the maximum value of the prediction in the category channel dimension and using it as proxy annotation information.
[0050] Furthermore, in step 43, the formula for adjusting the logic value in the deviation-aware false detection and missed detection suppression module is expressed as equations (9), (10), and (11):
[0051]
[0052]
[0053]
[0054] In equations (9), (10), and (11) above, |·| represents the modulus of the logic value, which is used to suppress false positives and false negatives in the prediction results.
[0055] Furthermore, in step 61, the prediction result... The formulas are expressed as in equations (12), (13), and (14):
[0056]
[0057]
[0058]
[0059] In equations (12), (13), and (14) above, σ represents the Softmax activation function, and the formula for Softmax is expressed as in equation (15):
[0060]
[0061] In the above formula (15), C represents the total number of categories, and L i This represents the i-th element of the logical value L.
[0062] Furthermore, in step 6, the training loss for training the cross-fabric fine-grained defect detection model is expressed as equation (16):
[0063]
[0064] In equation (16) above, w represents the weight of the loss in the target domain, which is calculated using the average confidence level of the predictions on the target domain samples, as shown in equation (17):
[0065]
[0066] In equation (17) above, H and W represent the height and width of the target domain image, respectively. This indicates an indicator function that returns 1 if a condition is met, and 0 otherwise. Indicates the prediction P t The component at the i-th pixel.
[0067] Compared with the prior art, the superior effects of the present invention are as follows:
[0068] 1. The fine-grained defect detection method across fabrics in blurred lighting scenarios described in this invention fully utilizes the defect detection knowledge learned by the source domain model in simple scenarios and maintains good defect detection performance in environments with low-brightness blurred lighting conditions, thus exhibiting good generalization performance. Furthermore, this method is not limited to well-lit scenarios or specific types of fabric defect detection; it addresses the impact of low-brightness blurred lighting conditions, helping the trained defect detection model to perform well in various real-world scenarios, demonstrating universality and versatility.
[0069] 2. The fine-grained defect detection method for fabrics under blurred lighting scenes described in this invention achieves a finer detection granularity based on semantic segmentation, which can help the model pay attention to defects of different scales and shapes in the image, thereby improving the detection accuracy of the defect detection model on various types of defects and greatly reducing the occurrence of false detections and missed detections.
[0070] 3. The fine-grained defect detection method for fabrics under blurred lighting conditions described in this invention requires only the original image data in the target domain images for training, without the need for annotation. This improves detection accuracy while saving the time and labor costs required to re-collect and annotate the target domain training data. Attached Figure Description
[0071] Figure 1 This is a schematic diagram of the cross-fabric fine-grained defect detection model described in an embodiment of the present invention;
[0072] Figure 2 This is a schematic diagram illustrating the low-brightness blurry illumination modulation module processing sample data according to an embodiment of the present invention. Detailed Implementation
[0073] To better understand the above-mentioned objectives, features and advantages of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of this application can be combined with each other.
[0074] Example
[0075] like Figure 1 As shown, the cross-fabric fine-grained defect detection model includes a basic defect detection module, a low-brightness blurred lighting modulation module, and a bias-aware false positive / false negative suppression module. The basic defect detection module is constructed using an encoder with a self-attention mechanism and a highly efficient decoder optimized for intensive visual tasks. The low-brightness blurred lighting modulation module significantly improves the model's generalization ability in low-brightness blurred lighting scenarios. The bias-aware false positive / false negative suppression module effectively improves the detection rate of fabric defects and increases the accuracy of detection results when there is significant domain bias. These three modules complement each other, jointly enhancing the generalization ability of the fabric defect detection model in low-brightness blurred lighting scenarios. Specifically, the basic defect detection module supports semantic segmentation, enabling accurate detection of defect areas at the pixel level. The low-brightness blurred lighting modulation module uses a physical model and image priors to mitigate the impact of low-brightness blurred lighting conditions on fabric defect perception with high efficiency and quality. The accuracy of defect detection has been improved. The proposed bias-aware false positive and false negative suppression module provides a more robust optimization target for the training of the entire model. It can further reduce the impact of low-brightness and blurred lighting scenes, and at the same time respond to the domain bias caused by changes in fabric color, texture and other attributes. This greatly improves the defect detection capability and accuracy of the entire model in more complex situations in real-world applications, and prevents false positives and false negatives. By combining the above three modules, the defect detection model of the existing production line can be adjusted and deployed to a new fabric production line with different colors, low-brightness and blurred lighting conditions and complex operating environment. This ensures that it can also have good performance on the new production line. At the same time, there is no need to provide additional manual annotations for the fabrics of the new production line as training references. This allows the method in this embodiment to effectively solve the problem of high cost, time and manpower for collecting data samples in new scenarios while improving the performance and generalization ability of fabric defect detection. This helps the industry reduce expenses while improving fabric quality.
[0076] The method for detecting fine-grained defects across fabric pieces in blurred lighting scenarios includes:
[0077] Step 1: The lightweight fabric imaging module collects fabric images under new low-brightness, blurred lighting conditions to form a fabric defect detection dataset for the target domain. This data is acquired by deploying RGB cameras on the production line, capturing fabric images under these new low-brightness, blurred lighting conditions in the actual operating environment of a textile factory production line. Differences in fabric types include variations in pattern and texture. Changes in production line lighting conditions can be reflected in brightness, color, and uniformity of light. The image data covers common fabric defect types in the textile industry, such as color difference, holes, and fuzz. Each image will show one or more defects. The collected source domain labeled fabric defect detection image dataset is denoted as D. s The newly acquired target domain unlabeled fabric defect detection image dataset is defined as D. t The source domain images were acquired under good lighting conditions and have high-quality human annotations; the target domain dataset was acquired under blurry lighting conditions and has no corresponding annotations.
[0078] Step 2: Construct a basic module for fine-grained defect detection. This module uses a self-attention-based encoder and a decoder optimized for dense visual tasks. It combines the global relational modeling capabilities of the self-attention mechanism with the efficient perception capabilities of dilated spatial pyramid pooling. Simultaneously, it fully utilizes the multi-scale features generated by the encoder to improve the model's detection performance on fabric defects of different sizes. In this module, the MiT-B5 network model pre-trained on ImageNet is used as the encoder F for feature extraction. The method described in this embodiment is based on all four stages of extracted features. The decoder uses these features as input and fuses all features using dilated convolution to obtain a higher-quality feature representation. This refined feature is then used by a classifier to output the defect detection result. However, the fine-grained defect detection module only implements the basic semantic segmentation process and has poor generalization ability. Therefore, it is necessary to improve the accuracy of the fine-grained defect detection module across fabric defects.
[0079] Step 3: Construct a domain-aware adaptation module to enhance model generalization and improve accuracy. This includes:
[0080] Step 3.1: Create a low-brightness blurry illumination modulation module. The low-brightness blurry illumination modulation module summarizes and uniformly alleviates the impact of low-brightness blurry illumination scenes on image perception effects. It uses a lightweight plug-and-play module to characterize and eliminate the domain differences brought about by illumination.
[0081] Step 3.2: Create a bias-aware false detection and false negative suppression module. To address the serious problem of false detection and false negative in cases with large scene domain bias, the training optimization objective is redesigned to suppress two types of erroneous predictions: non-detection and false alarm in the detection of defects in unfamiliar environments. By combining the low-brightness blurry illumination modulation module and the bias-aware false detection and false negative suppression module, knowledge transfer from the source domain to the target domain can be reliably achieved, thereby improving the defect detection performance and generalization of the model in the target domain.
[0082] Step 4, Preprocessing for the cross-fabric fine-grained defect detection method:
[0083] Step 4.1, randomly sample a source domain data X. s and a target domain sample data X t Input a cross-fabric fine-grained defect detection model;
[0084] Step 4.2, Target Domain Sample Data X t After passing through the low-brightness blurry illumination modulation module, target domain enhancement samples that are beneficial for perception are obtained.
[0085] Step 5, Perception and Error Suppression in Cross-Fabric Fine-Grained Defect Detection Methods:
[0086] Step 5.1, Source Domain Sample Data X s After passing through the MiT-B5 backbone self-attention network F, multi-layered output feature maps are obtained. These feature maps from the source domain are then input into the decoder G to obtain the logical value L for defect prediction on the source domain samples. s Target domain data X t and All features are obtained through the MiT-B5 backbone network F, which generates multi-layer feature maps. These feature maps are then passed through the decoder G to obtain the logical value L of the target domain defect detection prediction result. t and
[0087] Step 5.2, for the input image of the target domain Using the network to generate fake tags As proxy annotation information, it also guides the original image X in the target domain. t and enhanced images Training;
[0088] Step 5.3, generate all predicted logical values L s L t , The data is fed into the bias-aware false positive and false negative suppression module for adjustment to suppress potential erroneous predictions, resulting in a suppressed logic value.
[0089] Step 6, Training on the method for fine-grained defect detection across fabrics:
[0090] Step 6.1: Calculate the final fabric defect detection prediction results using the suppressed logic values. Then, the loss functions for the prediction results are calculated using the real annotation information in the source domain and the proxy annotation information in the target domain, respectively.
[0091] Step 6.2: Weight the target domain loss using the target domain confidence level w, and then calculate the complete loss. The stochastic gradient descent algorithm is used for backpropagation to update the model parameters and minimize the loss function, thereby achieving reliable knowledge transfer from the source domain to the target domain and improving the generalization and performance of the target domain.
[0092] Step 6.3: Repeat the above steps to train the model until it converges or reaches the maximum number of iterations.
[0093] Step 7: Using the cross-fabric fine-grained defect detection method, the fabric image data of the target domain fabric production line collected in real time is input into the trained fabric defect detection model for defect detection, and the prediction result with the highest classification confidence in the model output is selected as the final detection result.
[0094] In the above embodiments, the low brightness refers to a brightness of less than 30%.
[0095] Regarding the training dataset, it contains a source domain with labeled information:
[0096]
[0097] A target domain without annotation information:
[0098]
[0099] Each field contains only one type of fabric image data, where, It is an image from the source domain, N s It represents the total number of images in the source domain, where (i) represents the i-th image. Let H represent the height and W of the i-th image in the source domain, where each image has 3 channels. Represents pixel-by-pixel annotations of the source domain;
[0100] Regarding the fine-grained defect detection module, the cross-fabric fine-grained defect detection method constructs a module based on a self-attention mechanism encoder and a decoder optimized for dense visual tasks. This module combines the global relation modeling capability of the self-attention mechanism with the efficient perception capability of hollow space pyramid pooling. Furthermore, this module fully utilizes the multi-scale features generated by the encoder to improve the model's detection performance on fabric defects of different sizes. In this module, the MiT-B5 network model pre-trained on ImageNet is used as the encoder F for feature extraction. The cross-fabric fine-grained defect detection method is based on all four stages of extracted features. In progress, among which f i C represents the feature map extracted from the i-th layer. i H represents the number of channels in the feature map of the i-th layer. i W represents the height of the feature map at layer i. i The width of the i-th layer feature map is represented by these features. The decoder takes these features as input and fuses all features in a dilated convolution to obtain a higher quality feature representation. This refined feature is finally passed to the classifier to complete the output of the defect detection result.
[0101] Regarding the domain-aware adaptation module, such as Figure 1-2 As shown, a source domain sample {X} is randomly sampled. s Y s} and a target domain sample Input the cross-fabric fine-grained defect detection model; the cross-fabric fine-grained defect detection model is... Figure 1 The portion within the dashed box represents the target domain sample data X. t First, a low-brightness blurry illumination modulation module is used to obtain enhanced samples that are beneficial for network perception. The low-brightness blurry illumination modulation module is designed based on the following formula:
[0102] A(x)=tr(x)C(x)+(1-tr(x))B,
[0103] Among them, X t and For the original image C(x) and the enhanced image A(x) in the above formula, respectively, B represents global illumination estimation, and tr(x) is represented as:
[0104]
[0105] avg sat η represents the mean estimate of saturation in an image. trThe weighting coefficients represent the enhancement level, where z∈N(x) represents a selected pixel z in a region near position x, and C t (z) represents the value of the t channel of the image at that point, B t X represents the value of the t-channel after global illumination estimation, representing all sample data. s X t , After passing through the MiT-B5 backbone self-attention network, multi-layered output feature maps are obtained. Next, feature maps of the source and target domains The values will be fed into decoder G to obtain the logical values for defect prediction:
[0106]
[0107] L t Used to predict probability value P t =σ(L t ), Used to predict probability values It was further used to calculate pseudo-labels. As proxy annotation information on the target domain;
[0108] All logical values L in the source and destination domains s L t , The input deviation sensing false detection and missed detection suppression module is adjusted to obtain a new logic value by suppressing the modulus of the logic value:
[0109]
[0110]
[0111]
[0112] Suppressing the logistic magnitude can help alleviate over-tuning of parameters during model training and optimization, thereby reducing false positives and false negatives in the prediction results. Further calculations of the prediction results will then be performed.
[0113]
[0114] The corresponding loss function can be calculated:
[0115]
[0116] The final loss function is obtained by weighted summation of the loss functions for the source and target domains. The weight w represents the confidence level of the model's prediction on the target domain image, derived from:
[0117]
[0118] The calculation yielded, where It is an indicator function, where H and W are the height and width of the image, respectively, and the weight w describes the proportion of confidence predictions in the target domain image prediction, thereby helping to control the degree to which images in the target domain participate in training;
[0119] Calculate the overall loss of the model:
[0120]
[0121] In the loss function Indicates source domain loss. This represents the loss corresponding to the original image in the target domain. This represents the loss corresponding to the image after target domain augmentation. During model training, the stochastic gradient descent algorithm is used for backpropagation to update the model parameters and minimize the loss function, thereby achieving reliable knowledge transfer from the source domain to the target domain and improving the generalization and performance of the target domain.
[0122] The training process for the cross-fabric fine-grained defect detection model is as follows:
[0123] S1. Given the source domain D s and target domain D t enhancement coefficient η tr Maximum number of iterations I;
[0124] S2. Initialize the backbone network using the MiT-B5 network pre-trained on ImageNet, while randomly initializing the remaining parameters of the model;
[0125] S3. Randomly sample a source domain sample {X} s Y s} and a target domain sample data X t X t Input the low-brightness blurry illumination modulation module to obtain the enhanced sample.
[0126] S4. X s X t , Input the encoder F of the cross-fabric fine-grained defect detection model to obtain multi-layered output feature maps. feature map The data is then fed into the decoder G to obtain the logical values L of the respective prediction results. s L t ,
[0127] S5. Network model enhances images in the target domain. Generate pseudo tags As agent labeling information;
[0128] S6. Transfer the logical value L s L t , The data is fed into the bias-aware false detection and missed detection suppression module for adjustment, resulting in the suppressed logic value.
[0129] S7. Calculate their respective final defect detection prediction results using the suppressed logic values. Furthermore, the loss function for the prediction result corresponding to each image is calculated.
[0130] S8. Calculate the overall loss of the model. Backpropagation is performed using the stochastic gradient descent algorithm to update the model parameters;
[0131] S9. Repeat S3 to S8 until the maximum number of iterations I is reached or the model parameters converge;
[0132] Model usage phase: The fabric image data of the target domain fabric production line collected in real time is input into the trained cross-fabric fine-grained defect detection model for defect detection, and the prediction result with the highest classification confidence in the model output is selected as the final detection result.
[0133] This invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the invention as claimed. The scope of protection of this invention is defined by the appended claims.
Claims
1. A method for detecting fine-grained defects across fabrics in a blurred lighting scenario, characterized in that, Comprise: Step 1, the cloth lightweight imaging module collects a source domain labeled cloth defect detection image dataset and a target domain unlabeled cloth defect detection image dataset Wherein, the target domain unlabeled cloth defect detection image dataset is formed by collecting cloth images under a low-brightness blurred light scene with a brightness less than 20 nits; Step 2, build the defect fine-grained detection base module and the domain perception adaptation module: The defect fine-grained detection base module is a basic network architecture constructed based on the encoder of self-attention mechanism and the decoder optimized for dense visual tasks, which functions to extract fine-grained features of the cloth; The domain perception adaptation module includes a low-brightness fuzzy light modulation module and a bias-aware false alarm and missed detection suppression module; The defect fine-grained detection base module and the domain perception adaptation module are two components in the cross-cloth fine-grained defect detection model; Step 3, sampling one source domain sample data and one target domain sample data as input of the cross fabric fine-grained defect detection model, the target domain sample data obtained by the low-brightness blur light modulation module, the target domain enhanced sample beneficial to perception ; Step 4, obtaining logical values for flaw prediction on source domain sample data obtaining logical values for flaw prediction on source domain sample data , obtaining logical values for flaw prediction on target domain sample data and target domain augmented sample , obtaining logical values for flaw detection prediction results of target domain and , obtaining logical values after suppressing false prediction results according to logical values : Step 41, source domain sample data Through the MiT-B5 main trunk self-attention network After obtaining the output feature map of multiple layers, the feature map is input into the decoder In the middle, the logical value of the defect prediction on the source domain sample is obtained ; target domain sample data And the target domain enhanced sample Both pass through the MiT-B5 main network Obtain the feature map of multiple layers, and the feature map is respectively input into the decoder Get the logical value of the target domain defect detection prediction result And ; Step 42, for target domain enhanced samples , the pseudo label generated by the network As proxy annotation information, while guiding the training of target domain sample data And target domain enhanced samples Step 43, the predicted logic value is sent into the bias-aware false positive / negative suppression module for adjustment to suppress potential false prediction results, to obtain a suppressed logic value ; Step 5, train the cross-cloth fine-grained defect detection model: Step 51, using the logic value after inhibition The final fabric defect detection prediction results are calculated respectively The respective prediction result loss functions are calculated using the real label information on the source domain and the proxy label information on the target domain respectively ; Step 52, using target domain confidence degree Weighting target domain loss, calculating complete loss And using random gradient descent algorithm to reverse propagate, updating parameters of the model, and minimizing the loss function, realizing reliable knowledge transfer from source domain to target domain to improve generalization and performance of target domain. Step 53, repeat steps 51-52 for training until the model converges or reaches the maximum number of iterations; Step 6, input the cloth image data of the target domain cloth production line collected in real time into the trained cross-cloth fine-grained defect detection model for defect detection, and select the prediction result with the maximum classification confidence in the model output result as the final detection result.
2. The method of claim 1, wherein, In step 2, the domain perception adaptation module includes: Create a low-brightness fuzzy light modulation module; Create a bias-aware false alarm and missed detection suppression module.
3. The method of claim 1, wherein, In step 1, and are represented by formula (1) and formula (2), respectively: ……(1), ……(2), In equations (1) and (2) above, This represents a dataset of source domain labeled fabric defect detection images. Unlabeled fabric defect detection image dataset for the target domain. It's an image from the source domain. This is the total number of source domain images, indicated by the superscript. Indicates the first Zhang picture; It is an image of the target domain. It is the total number of images in the target domain. Represent the source domain and the target domain respectively. The height of the picture is And its length is Each image in the image has 3 channels, and This represents the pixel-by-pixel annotation of the source domain.
4. The method of claim 1, wherein, The low-brightness fuzzy light modulation module in step 3 is based on the physical model as formula (3): ……(3), In the above equation (3), is a certain pixel of the picture under low brightness blurry lighting conditions, represents the transmittance of light at the pixel point under the current lighting scene, represents the estimation of the global lighting condition, is the enhanced picture obtained after removing the influence of the lighting condition; The calculation is as follows (4): ……(4), In the above formula (4), This represents the mean estimate of saturation in the image. Weighting coefficients representing the degree of enhancement. Indicates position A selected pixel in a nearby area , This indicates the z-th pixel in the image. The values of each channel, where... These represent the green, blue, and red color channels, respectively. Indicates global illumination estimation Channel values, target domain sample data As in equation (3) The image is input into the low-brightness blurry illumination modulation module to obtain the enhanced image. As .
5. The method of claim 1, wherein, In step 41, the formula representation for predicting the logical value on the source domain is as formula (5): ……(5), In the above formula (5), The source domain sample is represented by the encoder The first Layer feature map generated by the encoder, The number of layers of the encoder output feature map, The prediction logic value obtained after the feature map passes through the decoder The target domain sample And the target domain enhanced sample The formula representation of the corresponding prediction logic value is as formula (6), (7): ……(6), ……(7), In the above formula (6), represents generated by the encoder In the above formula (7), the feature map of the first layer generated by the encoder, represents the number of layers of the encoder output feature map, represents the prediction logic value obtained after the feature map passes through the decoder In the above formula (8), represents generated by the encoder In the above formula (9), the feature map of the first layer generated by the encoder, represents the number of layers of the encoder output feature map, represents the prediction logic value obtained after the feature map passes through the decoder In the above formula (10), 6. The method of claim 5, wherein the method further comprises: In step 42, the formula representation of the agent annotation information is calculated by the formula representation of the agent annotation information is calculated by the formula representation of the agent annotation information is calculated by ……(8), In the above equation (8), denotes the enhanced target domain picture corresponding prediction logic value, denotes the Softmax activation function, denotes the prediction of the model on , and denotes the pseudo label obtained by taking the maximum value of the prediction in the class channel dimension as the proxy labeling information.
7. The method of claim 1, wherein, In step 43, the formula representation for adjusting the logical value in the bias-aware false alarm and missed detection suppression module is as formula (9), (10), (11): ……(9), ……(10), ……(11), In the above equations (9) (10) (11), The module length of the logic value is used to suppress the false detection and missed detection phenomenon in the prediction result.
8. The method of claim 1, wherein, In step 51, the prediction result is expressed by the formulae (12), (13), (14): ……(12), ……(13), ……(14), In the above equations (12) (13) (14), denotes a Softmax activation function, the formula of Softmax is represented as equation (15): ……(15), In the above equation (15), denotes the total number of classes, denotes a logical value of the first element.
Citation Information
Patent Citations
A small target semantic segmentation method combining object detection
CN109145713B
Method for assisting object detection through semantic segmentation
CN109784386A
A method and system for detecting composite defects in images based on semantic segmentation
CN114820579B
Convolutional neural network cloth defect detection method based on extreme learning machine
CN111260614A
Fabric defect detection method based on improved Scaled-YOLOv4 model
CN114882011A