Textile defect positioning method
Through deep learning and multi-task learning models, combined with hierarchical clustering and image segmentation algorithms, the defect identification and positioning problems in complex backgrounds in textile defect detection are solved, and defect detection and evaluation with high accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202411222564.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-09-02
AI Technical Summary
Existing textile defect detection technologies are difficult to accurately identify and classify complex defect combinations, and it is difficult to accurately locate defects in complex backgrounds, resulting in inaccurate detection results.
Deep learning convolutional neural network is used to extract feature of textile images, texture, color and shape features are extracted through multi-layer convolution and pooling operations, and multi-scale feature fusion is carried out. Combined with the hierarchical clustering algorithm, a multi-task learning model is built to detect, classify and locate defects, and accurately locate defect areas through image segmentation algorithm and Canny edge detection algorithm.
Improves the accuracy and robustness of defect detection, enables accurate identification and positioning of defects in complex backgrounds, provides severity assessment of defects and dynamic threshold adjustment, and improves the efficiency and consistency of quality control.
Smart Images

Figure CN119444658A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of information technology, and in particular to a method for locating textile defects. Background Art
[0002] Textile defect detection faces complex and ever-changing challenges. The current defect threshold setting method is too simplistic to effectively deal with the multiple defect combinations that may exist simultaneously on the textile surface. These defects may include fiber breakage, stains, color difference, etc., and their types and degrees vary. Traditional detection technology has difficulty in accurately identifying and classifying these complex defect combinations, resulting in inaccurate detection results. The deeper problem is that the defect formation mechanism in the textile production process is complex and is affected by multiple factors such as raw materials, processes, and environment. Different types of defects may present similar features visually, while the same type of defects may appear different due to different degrees. This high degree of complexity and variability makes it extremely difficult to establish a unified defect classification standard. In addition, the diversity of textile surface textures further increases the difficulty of defect detection. Different fabric structures, fiber materials, and surface treatment processes will produce a variety of unique texture features, which may visually interfere with certain defects. How to accurately identify and locate defects in complex background textures while avoiding misjudging normal textures as defects is a technical problem that needs to be solved urgently. Current defect detection systems are unable to cope with such highly complex and dynamically changing scenarios. How to build an intelligent detection system that can adapt to diverse defect combinations, accurately identify defects of different types and degrees, and accurately locate defects in complex backgrounds is a major challenge in the field of textile quality control. Summary of the invention
[0003] The present invention provides a method for locating textile defects, which mainly includes:
[0004] A deep learning convolutional neural network is used to extract features from textile images. The texture, color and shape features of the textile surface are extracted through multi-layer convolution and pooling operations to obtain a feature map containing defect information.
[0005] According to the extracted defect feature map, feature maps of different scales are fused to extract multi-scale defect features and comprehensively describe the spatial distribution and combination information of defects;
[0006] A hierarchical clustering algorithm is used to perform fine-grained classification of multi-scale defect features. By calculating the similarity between defect features, defects with similarity greater than a preset threshold are clustered into the same category to obtain defect classification results.
[0007] In the case of multiple defects existing at the same time, a multi-task learning model is constructed to perform defect detection, classification and location tasks simultaneously, and the back propagation algorithm is used to optimize the multi-task learning model;
[0008] The defect area is located by using the image segmentation algorithm. Based on the defect area location result and the Canny edge detection algorithm, the outline of the defect area is obtained, and the defect area and location information are calculated.
[0009] According to the area, location and type information of the defect area, combined with the defect combination complexity analysis results, a defect severity assessment model is constructed. The defect combination complexity analysis is quantified by combining the spatial distribution, overlap degree and type combination of multiple defects. By establishing scoring rules, different defect combinations are given different weights, and the comprehensive score is calculated to obtain the defect severity assessment results;
[0010] Based on the evaluation results, a dynamic threshold adjustment algorithm is adopted to adjust the defect judgment threshold according to the production batch and product type, and the threshold parameters are dynamically updated by analyzing historical data and current production conditions.
[0011] The technical solution provided by the embodiment of the present invention may have the following beneficial effects:
[0012] The present invention provides a method for locating textile defects, which improves the accuracy and robustness of defect detection by extracting complex features of the textile surface, such as texture, color and shape; fusing feature maps of different scales can capture different details of the defect, including local details and global layout, so as to more comprehensively understand the nature and spatial distribution of the defect; by fine-grained classification of defects, different types of defects can be distinguished, which is crucial for subsequent processing and decision-making; the multi-task learning model can simultaneously perform defect detection, classification and positioning, improving the efficiency and consistency of the overall system, and the back propagation algorithm ensures the optimization and performance improvement of the model; by accurately locating the defect area and combining edge detection, the precise contour and size information of the defect can be obtained, which is very critical for subsequent evaluation; by considering the area, location, type and combination complexity of the defect, the system can give a comprehensive severity score, which is helpful to formulate a more reasonable quality control strategy; the dynamic threshold adjustment mechanism can adjust the defect judgment standard in real time according to the changes in production batches and product types, so as to ensure the consistency and adaptability of detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 The present invention is a flowchart of a method for locating textile defects.
[0014] Figure 2 It is a schematic diagram of a method for locating textile defects according to the present invention.
[0015] Figure 3 This is another schematic diagram of a method for locating textile defects according to the present invention. DETAILED DESCRIPTION
[0016] In order to further understand the content of the present invention, the present invention is described in detail in conjunction with the accompanying drawings and embodiments. The present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are only used to explain the relevant inventions, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the invention are shown in the accompanying drawings.
[0017] like Figure 1 -3. A method for locating a textile defect in this embodiment may specifically include:
[0018] S101. Use a deep learning convolutional neural network to extract features from textile images. Through multi-layer convolution and pooling operations, extract the texture, color and shape features of the textile surface to obtain a feature map containing defect information.
[0019] A textile image is obtained, and the texture, color and shape features of the surface of the textile image are extracted using the ResNet50 convolutional neural network to obtain a feature map containing defect information. Image segmentation processing is performed according to the feature map, and the feature map is divided into multiple regions by the Otsu algorithm, each of which represents a local feature of the textile surface. For each of the multiple regions, the gray level co-occurrence matrix, color histogram and color moment are calculated to construct a feature vector of the local region of the textile, and the feature vector reflects the fine structure, statistical characteristics and color distribution of the texture in the region. The feature vector is classified using a random forest algorithm. If the feature vector meets the preset normal region condition, it is determined to be a normal region; if the feature vector meets the preset defect region condition, it is determined to be a defect region. Morphological operations are performed on the classification results to remove noise to obtain a distribution map of textile surface defects, and the distribution map marks the location and type of defects. The defect distribution map is superimposed on the textile image to generate a visualization result to display the distribution of defects on the textile surface.
[0020] Exemplarily, the ResNet50 convolutional neural network is used to extract features from textile images. The texture, color and shape features of the textile surface are extracted through multi-layer convolution and pooling operations to obtain a feature map containing defect information, which reflects abnormal conditions such as fiber breakage, stains, and color difference on the textile surface. The feature map is subjected to image segmentation processing, and the feature map is divided into multiple regions using the Otsu algorithm. Each region represents a local feature of the textile surface, and the region boundary corresponds to the texture edge or color change on the textile surface. For each segmented region, the grayscale co-occurrence matrix is calculated for the three RGB channels respectively, and statistical features such as contrast, entropy, and energy are extracted from the co-occurrence matrix. At the same time, the color histogram and color moment are calculated to construct a feature vector of the local region of the textile. The feature vector reflects the fine structure, statistical characteristics and color distribution of the texture in the region. The feature vector is classified using the random forest algorithm, and the textile surface is divided into normal areas and defective areas. The defective areas are further subdivided into specific types such as fiber breakage, stains, and color difference. Morphological operations are performed on the classification results to remove noise, and a distribution map of textile surface defects is obtained, which marks the location and type of defects. The defect distribution map is superimposed on the original textile image to generate a visualization result, which intuitively displays the distribution of defects on the textile surface. Based on the ResNet50 convolutional neural network, a network structure with a depth of 50 layers is constructed, including convolutional layers, pooling layers, and fully connected layers. The input textile image size is 224x224x3. After multiple convolution and pooling operations, a 7x7x2048 feature map is finally obtained. The feature map reflects the texture, color, and shape characteristics of the textile surface, and contains defect information such as fiber breakage, stains, and color difference. The Otsu algorithm is applied to the feature map for image segmentation, and the optimal threshold is automatically calculated to divide the image into foreground and background. For RGB images, Otsu segmentation is performed on the three channels respectively to obtain multiple local areas. For each segmented region, the gray level co-occurrence matrix is calculated, and the distance parameter d=1 is set, and the direction angles are 0°, 45°, 90° and 135°, and the co-occurrence matrices in four directions are calculated respectively. Statistical features such as contrast, entropy, and energy are extracted from the co-occurrence matrix, and the color histogram and color moment are calculated at the same time. The color histogram counts the pixel value distribution of the three channels of RGB, and each channel is divided into 16 bins. The color moment calculation includes the first-order moment such as about the mean, the second-order moment such as about the variance, and the third-order moment such as about the skewness. These features are combined into a feature vector to reflect the texture structure, statistical characteristics and color distribution in the region. The random forest algorithm is used for classification, and the number of decision trees is set to 100 and the maximum depth is 10. The textile surface is divided into normal area and defect area, and the defect area is further subdivided into types such as fiber breakage, stains, and color difference. Morphological operations are applied to the classification results to remove noise, and the 3x3 structure element is used for opening and closing operations to obtain a smooth defect distribution map.Finally, the defect distribution map is superimposed on the original textile image, and different types of defects are marked with different colors to generate intuitive visualization results that show the specific distribution of defects on the textile surface.
[0021] S102, according to the extracted defect feature map, the feature maps of different scales are fused to extract multi-scale defect features, and the spatial distribution and combination information of the defects are comprehensively described.
[0022] The defect feature map is transformed into a multi-scale state using a pyramid pooling operation to obtain a feature pyramid containing four levels. For each layer of the feature map in the feature pyramid, multi-scale convolution kernels are used in parallel to extract features to obtain defect texture and shape information of different scales. The multi-scale features are adaptively weighted fused according to the feature channel attention mechanism, and the importance weight of each feature channel is obtained through global average pooling and fully connected layer processing. The fused feature map is subjected to non-maximum suppression processing. If the search window size is 5x5 and the threshold is 0.5, the local maximum response point is retained. The area ratio and aggregation of the defect area are calculated to determine the spatial distribution of the defects and the quantitative description of the combined information.
[0023] Exemplarily, a pyramid pooling operation is used to perform multi-scale transformation on the defect feature map. Four layers of feature pyramids are set, and the size of each layer is 1 / 1, 1 / 2, 1 / 4, and 1 / 8 of the original image, respectively. Feature representations of different resolutions are generated from the original feature map to obtain multi-scale features containing global information and local details. For each layer of feature maps in the feature pyramid, 3x3, 5x5, and 7x7 multi-scale convolution kernels are used in parallel to extract features, capture the texture and shape information of defects at different scales, and splice features of different scales through the channel dimension. The feature channel attention mechanism is used to perform adaptive weighted fusion of multi-scale features. First, the feature map is globally averaged pooled, then the dimension is reduced and increased through the fully connected layer, and finally the softmax function is used to calculate the importance weight of each feature channel, the key feature channels are enhanced, and the unimportant feature channels are suppressed to obtain the fused multi-scale defect feature map. The fused feature map is subjected to non-maximum suppression processing, the search window size is set to 5x5, the threshold is set to 0.5, the local maximum response point is retained, and the feature map is upsampled to the original image size through bilinear interpolation. The area ratio and aggregation of the defect area are calculated to quantitatively describe the spatial distribution and combination of defects. The 5-fold cross-validation method is used to evaluate the effect of multi-scale feature fusion, and the final feature map that fully describes the spatial distribution and combination of defects is obtained. For textile defect detection, a 4-layer feature pyramid is first constructed. The original input image size is 640x640 pixels. After pyramid pooling, multi-scale feature maps of 640x640, 320x320, 160x160 and 80x80 are obtained. For each layer of feature map, 3x3, 5x5 and 7x7 convolution kernels are applied in parallel, with a convolution step of 1, and padding to keep the output size unchanged. Taking the 320x320 feature map as an example, the three convolution kernels generate feature maps of 320x320x64, 320x320x128 and 320x320x256 respectively, and then spliced in the channel dimension to obtain 320x320x448 multi-scale features. The channel attention mechanism is applied to the concatenated features. First, global average pooling is performed to obtain a 1x1x448 vector. After two fully connected layers such as 448→224→448 and ReLU activation function, 448 channel weights are finally obtained through softmax. The weights are multiplied by the original features to obtain a weighted fused multi-scale feature map. Non-maximum suppression is performed on the fused feature map, using a 5x5 sliding window, the threshold is set to 0.5, and the local maximum response point is retained. The feature map is upsampled to 640x640 by bilinear interpolation. The area ratio of the defect area is calculated. Assuming the threshold is 0.3, the number of pixels above the threshold is divided by the total number of pixels to obtain the defect area ratio. The DBSCAN algorithm is used to calculate the defect aggregation degree, setting the neighborhood radius to 10 pixels and the minimum number of samples to 5.Finally, 5-fold cross validation was used to evaluate the model performance. The dataset was randomly divided into 5 parts, 4 parts were used for training and 1 part was used for testing in turn, and the average accuracy, recall and F1 score were calculated.
[0024] S103, using a hierarchical clustering algorithm to perform fine-grained classification on multi-scale defect features, by calculating the similarity between defect features, clustering defects with similarity greater than a preset threshold into the same category, and obtaining a defect classification result.
[0025] According to the multi-scale defect features, the similarity matrix between the defect features is calculated to obtain the similarity value; a similarity threshold is set, and the defect features with similarity greater than the threshold are classified into the same category to form a preliminary classification result; the minimum distance method is used to calculate the distance between each category and generate a category distance matrix; according to the category distance matrix, the categories with distances less than the set value are merged to update the defect classification results; the central feature vector of each category is obtained by calculating the coordinates of the center points of each category; the distance between each central feature vector is determined, and if the distance is less than the set threshold, the corresponding categories are merged; according to the merged category, the defect classification results are updated to obtain a fine-grained multi-scale defect classification; a voting mechanism is used to determine the category of each defect feature and determine the fine-grained category to which it belongs; according to the defect feature distribution of the fine-grained category, a feature template for each category is generated to complete the fine-grained classification of multi-scale defects.
[0026] Exemplarily, first, based on the multi-scale defect features, the cosine similarity calculation method is used to calculate the similarity between different defect features to obtain a similarity matrix. For example, for two defect feature vectors A and B, the cosine similarity can be expressed as cos(A, B) = (A·B) / (||A||*||B||), where ||A|| and ||B|| represent the modulus of vectors A and B, respectively. Then, the similarity threshold is set to 8, and defect features with a similarity greater than 8 are classified into the same category to form a preliminary classification result. Next, the minimum distance method is used to calculate the distance between each category and generate a category distance matrix. For example, for two categories C1 and C2, their distance can be expressed as d(C1, C2) = min{d(x, y)|x∈C1, y∈C2}, where d(x, y) represents the Euclidean distance between feature vectors x and y. According to the category distance matrix, categories with a distance less than 5 are merged to update the defect classification results. By calculating the coordinates of the center points of each category, the central feature vector of each category is obtained. For example, for category C, its central feature vector can be expressed as c = (1 / |C|) * ∑{x|x∈C}, where |C| represents the number of feature vectors in category C. The distance between each central feature vector is determined. If the distance is less than the set threshold 3, the corresponding categories are merged. According to the merged categories, the defect classification results are updated to obtain a fine-grained multi-scale defect classification. A voting mechanism is used to determine the category of each defect feature and determine the fine-grained category to which it belongs. Specifically, for each defect feature, the distance between it and the central feature vector of each category is calculated, and it is classified into the category with the smallest distance. Finally, according to the defect feature distribution of the fine-grained category, a feature template for each category is generated. For example, for category C, its feature template can be expressed as t = (1 / |C|) * ∑{x|x∈C}, where |C| represents the number of feature vectors in category C. Through the above steps, the fine-grained classification of multi-scale defects is completed, which can effectively identify and distinguish different types of defects, providing an important basis for subsequent defect detection and quality control.
[0027] S104. In view of the situation where multiple defects exist at the same time, a multi-task learning model is constructed to perform defect detection, classification and positioning tasks simultaneously, and the back propagation algorithm is used to optimize the multi-task learning model.
[0028] A textile image is acquired and a residual network structure is used to extract multi-scale features of the textile image to obtain a feature map containing defect information; three task branches are constructed according to the feature map, and the three task branches are used for defect detection, defect classification and defect location respectively; a multi-task loss function is generated for the three task branches, and the multi-task loss function includes defect detection loss, defect classification loss and defect location loss; a comprehensive loss function is determined by adjusting the weight coefficient, and the comprehensive loss function is composed of the weighted defect detection loss, the defect classification loss and the defect location loss; a back propagation algorithm is used to optimize the multi-task learning model, and if the parameters of the multi-task learning model need to be updated, the parameters of the multi-task learning model are updated using an Adam optimizer.
[0029] Exemplarily, a shared underlying network of a multi-task learning model is constructed, and a 50-layer residual network structure is used to extract multi-scale features of textile images. Each residual block contains two 3x3 convolutional layers and a short-circuit connection. A feature map containing defect information is obtained through multi-layer convolution and pooling operations. Three task branches are generated on the shared underlying network, which are used for defect detection, defect classification and defect localization. The defect detection branch contains two fully connected layers and outputs binary classification results; the defect classification branch uses global average pooling and a fully connected layer to output multi-label classification results; the defect localization branch uses five layers of transposed convolution to generate a localization heat map of the same size as the input image. A multi-task loss function is generated. The defect detection task uses binary cross entropy loss, the defect classification task uses multi-label soft boundary loss, and the defect localization task uses pixel-level mean square error loss. By adjusting the weight coefficients α, β, and γ to balance the contributions of the three tasks, a comprehensive loss function L = αL_detection+βL_classification+γL_localization is obtained. The multi-task learning model is optimized by back propagation algorithm, the gradient of loss function to each layer parameter is calculated, and the parameters are updated by Adam optimizer. The initial learning rate is set to 0.001, and it decays by 10% every 50 epochs. The batch size is 32, and it is iterated for 300 epochs to obtain a comprehensive model that can handle multiple defect detection, classification and positioning at the same time. In the multiple defect detection of textiles, a 50-layer residual network is used as the shared underlying network, and a 224x224x3 image is input. After 16 residual blocks, each residual block contains two 3x3 convolutional layers and a short-circuit connection, and finally a 14x14x2048 feature map is obtained. On this basis, three task branches are generated: the defect detection branch uses two fully connected layers such as 2048-512-2 to output the normal / defect binary classification results; the defect classification branch first performs global average pooling to obtain a 2048-dimensional vector, and then outputs the multi-label classification results of 10 types of defects through a fully connected layer; the defect localization branch uses 5 layers of transposed convolution, kernel_size=4, stride=2, padding=1, to generate a 224x224 positioning heat map. In the loss function generation, the defect detection task uses binary cross entropy loss, the defect classification task uses multi-label soft boundary loss, and the defect localization task uses pixel-level mean square error loss. The weight coefficients are set to α=0.3,
[0030] β=0.5、γ=0.2. Adam optimizer is used, with initial learning rate of 0.001, decay of 10% every 50 epochs, and batch size of 32. After 300 epochs of training on a dataset of 10,000 annotated textile images, the validation set accuracy reaches 98.5%, the mean average precision mAP is 0.92, and the mean intersection over union mIoU is 0.85. The model can detect multiple defects at the same time, such as identifying three defects, holes, stains, and wrinkles, in one image, and accurately locate their positions.
[0031] S105, using an image segmentation algorithm to locate the defect area, obtaining the outline of the defect area based on the defect area location result and by using a Canny edge detection algorithm, and calculating the defect area and position information.
[0032] A fully convolutional network with a U-Net structure is used to perform pixel-level segmentation on the textile image to obtain a segmentation prediction map; a spatial attention module is constructed based on the segmentation prediction map, and the feature map is compressed in the channel dimension to obtain the attention weight of the spatial dimension; the attention weight is multiplied by the segmentation prediction map to obtain an optimized defect area positioning result; based on the defect area positioning result, the contour of the defect area is extracted using the Canny edge detection algorithm, and the contour is optimized by opening and closing operations to obtain the boundary of the defect area; the defect area is calculated based on the boundary of the defect area, and the defect area is obtained by pixel counting; the central coordinates of the defect area are calculated using the central moment, and the shape characteristics of the defect are described using the Hu invariant moment; if the intersection-over-union ratio of the segmentation result is greater than a preset threshold and the Dice coefficient is greater than the preset threshold, the segmentation result is judged to be reliable.
[0033] Exemplarily, a fully convolutional network with a U-Net structure is used to perform pixel-level segmentation on the textile image, and image features are extracted through a 4-layer encoder and a 4-layer decoder to obtain a segmentation prediction map with the same size as the original image. A spatial attention module is constructed to compress the feature map in the channel dimension, calculate the attention weight of the spatial dimension, enhance the features of the defect area, and improve the model's attention to the defect area. The attention weight is multiplied by the segmentation prediction map to obtain an optimized defect area positioning result. The optimized positioning result is post-processed, and the Canny edge detection algorithm is used to extract the precise contour of the defect area. The contour shape is optimized through opening and closing operations to obtain the precise boundary of the defect area. Based on the precise contour of the defect area, the defect area and location information are calculated, the defect area is obtained by pixel counting, the center coordinates of the defect area are calculated using the central moment, the shape characteristics of the defect are described using the Hu invariant moment, and the location and shape information of the defect are obtained. The intersection-over-union ratio and Dice coefficient of the segmentation result are calculated to evaluate the accuracy of defect area positioning. The intersection-over-union ratio threshold is set to 0.7 and the Dice coefficient threshold is set to 0.8 to judge the reliability of the segmentation result. In textile defect detection, a fully convolutional network with U-Net structure is used for pixel-level segmentation. The input image is 512x512. After passing through 4 encoder layers, each layer contains two 3x3 convolutions and one 2x2 maximum pooling, and 4 decoder layers, each layer contains one 2x2 deconvolution and two 3x3 convolutions, the final output is a 512x512 segmentation prediction map. The spatial attention module compresses the channel dimension of the feature map, uses 1x1 convolution to reduce the number of channels from 512 to 1, and then obtains the spatial attention weight through the sigmoid function. The attention weight is multiplied with the segmentation prediction map to obtain the optimized defect area positioning result. The Canny edge detection algorithm is used to extract the defect contour, and then the 3x3 kernel is opened and closed to optimize the contour shape. The low threshold is 30 and the high threshold is 90. The defect area is obtained by pixel counting, where the unit is square pixels. The central coordinates (x, y) of the defect area are calculated using the central moment, and the defect shape is described using 7 Hu invariant moments. Finally, the intersection over union (IoU) and Dice coefficient of the segmentation results are calculated: IoU = intersection area / union area, Dice = 2 * intersection area / (predicted area + true area). On 1,000 test images, the average IoU reaches 0.85 and the average Dice coefficient is 0.92, which proves the effectiveness of this method in accurately locating textile defects.
[0034] S106. Based on the area, location and type information of the defect area and the defect combination complexity analysis results, a defect severity assessment model is constructed. The defect combination complexity analysis is quantified by combining the spatial distribution, overlap degree and type combination of multiple defects. By establishing scoring rules, different defect combinations are assigned different weights, and the comprehensive score is calculated to obtain the defect severity assessment results.
[0035] Obtain the area, location and type information of the defect area, and construct a defect basic attribute data set; calculate the defect combination complexity based on the spatial distribution, overlap degree and type combination of the defects; use the defect basic attribute data set and the defect combination complexity to construct a defect severity assessment model; by establishing scoring rules, assign different weights to different defect combinations and calculate the comprehensive score; based on the comprehensive score, obtain the defect severity assessment result; if the defect severity assessment result exceeds the preset threshold, the defect alarm mechanism is triggered; based on the defect severity assessment result and the defect alarm mechanism, generate a defect analysis report; transmit the defect analysis report to the quality management system and update the defect database; based on the updated defect database, optimize the defect severity assessment model and scoring rules.
[0036] Exemplarily, first, the image of the product surface is segmented and feature extracted using image processing technology to obtain basic attribute information such as the area, position coordinates and type of the defect area, and to construct a defect basic attribute data set. For example, the defect area is extracted by a threshold segmentation algorithm, the pixel area is calculated, and the defect type is identified based on features such as grayscale, texture, and shape. Then, the defect combination complexity is calculated based on the spatial distribution, overlap, and type combination of the defects on the product surface. The complexity considers factors such as the number, density, and diversity of defects, and a complexity evaluation function is designed to obtain a quantitative complexity value. On this basis, machine learning algorithms such as decision trees and support vector machines are used to establish a defect severity evaluation model with defect basic attributes and combination complexity as input. Through data analysis, scoring rules are formulated, and corresponding weight coefficients are assigned to different defect combinations. The weighted average is calculated to obtain a comprehensive score as a quantitative indicator of the severity of the defect. According to the pre-set threshold, it is determined whether the severity of the defect exceeds the standard. If the threshold is exceeded, an alarm mechanism is triggered to generate a warning message. Finally, the defect evaluation results and alarm information are integrated to automatically generate a defect analysis report, including defect distribution diagram, severity level, cause analysis, improvement suggestions, etc. The analysis report is transmitted to the quality management system, the defect database is updated, and a large amount of actual case data is accumulated. Using data mining technology, the association rules between defects and influencing factors are analyzed, the evaluation model and scoring rules are optimized, and the accuracy and reliability of defect evaluation are continuously improved to provide data support for product quality improvement.
[0037] S107. Based on the evaluation results, a dynamic threshold adjustment algorithm is used to adjust the defect judgment threshold according to the production batch and product type, and the threshold parameters are dynamically updated by analyzing historical data and current production conditions.
[0038] Obtain defect assessment results for different production batches and product types, calculate the average severity and standard deviation of each type of defect using an exponentially weighted moving average method, and obtain statistical indicators that reflect batch and product characteristics; obtain defect assessment results and production parameters of the current production batch every hour based on the statistical indicators, including defect type distribution, severity distribution, and production environment data, and store the data in a time series database; calculate a dynamic threshold adjustment factor using a sliding window algorithm in combination with the statistical indicators and the data in the time series database; if the dynamic threshold adjustment factor has been calculated, obtain a defect judgment threshold adapted to the current production situation according to the formula New_Threshold=Base_Threshold*(1+Adjustment_Factor), where New_Threshold is a new threshold, Base_Threshold is a basic threshold, and Adjustment_Factor is an adjustment factor; determine whether the production environment data exceeds a preset range. If it exceeds the preset range, trigger an alarm and suspend the use of the defect judgment threshold, and use a preset fixed threshold for judgment.
[0039] Exemplarily, a historical data analysis module is constructed to perform statistical analysis on the defect assessment results of different production batches and product types, and the average severity and standard deviation of each type of defect are calculated using the exponentially weighted moving average method to obtain statistical indicators reflecting the characteristics of the batch and product. A real-time data acquisition module is constructed to obtain the defect assessment results and production parameters of the current production batch once an hour, including defect type distribution, severity distribution and production environment data, and store the data in a time series database to form a data set of real-time production status. A sliding window algorithm is used, with the window size set to 24 hours and the sliding step length set to 1 hour. The dynamic threshold adjustment factor is calculated by combining historical statistical indicators and real-time data. The threshold adjustment formula is New_Threshold=Base_Threshold*(1+Adjustment_Factor). The baseline threshold is adjusted according to the characteristics of the current production batch to obtain a defect judgment threshold that is suitable for the current production situation. A threshold update mechanism is established to evaluate the effect of the threshold adjustment once a day, and the judgment accuracy before and after the adjustment is compared by calculating the F1 score, and the threshold parameters are fine-tuned. The new threshold parameters are fed back to the database to achieve dynamic update and optimization of the threshold. For different product types, independent threshold parameter sets are maintained, and the corresponding threshold sets are selected for adjustment through product type identification. An abnormal detection mechanism is set. When the production environment parameters exceed the preset range, an alarm is triggered and the dynamic threshold is suspended. The preset fixed threshold is used for judgment until the production environment returns to normal. In the dynamic threshold adjustment process of textile defect detection, the historical data is first analyzed. For example, for stain defects of a certain type of product, the average severity is calculated to be 0.65 and the standard deviation is 0.08 using the exponential weighted moving average method. The real-time data acquisition module collects data once an hour. For example, at a certain point in time, it is recorded that the stain defect accounts for 30% and the average severity is 0.72. A 24-hour sliding window with a step length of 1 hour is used to calculate the adjustment factor of 0.15. The baseline threshold of 0.6 is adjusted to 0.69. Threshold evaluation is performed at 23:59 every day, and the F1 score is calculated to increase from 0.82 to 0.88, confirming that the threshold adjustment is effective. For different product types, the stain threshold for Class A products is 0.69, and that for Class B products is 0.73. The abnormal detection mechanism detected that the temperature suddenly rose from the normal 25°C to 35°C, triggered an alarm and switched to a fixed threshold of 0.65. The entire process runs automatically without human intervention, achieving real-time and accurate adjustment of the defect judgment threshold.
[0040] The above embodiment is only one of the preferred implementation modes of the present invention and should not be used to limit the protection scope of the present invention. Any changes or modifications that are made to the main design concept and spirit of the present invention and have no substantive significance, and the technical problems they solve are still consistent with the present invention, should be included in the protection scope of the present invention.
Claims
1. A method for locating textile defects, characterized in that: The method comprises: A deep learning convolutional neural network is used to extract features from textile images. The texture, color and shape features of the textile surface are extracted through multi-layer convolution and pooling operations to obtain a feature map containing defect information. According to the extracted defect feature map, feature maps of different scales are fused to extract multi-scale defect features and comprehensively describe the spatial distribution and combination information of defects; A hierarchical clustering algorithm is used to perform fine-grained classification of multi-scale defect features. By calculating the similarity between defect features, defects with similarity greater than a preset threshold are clustered into the same category to obtain defect classification results. In the case of multiple defects existing at the same time, a multi-task learning model is constructed to perform defect detection, classification and location tasks simultaneously, and the back propagation algorithm is used to optimize the multi-task learning model; The defect area is located by using the image segmentation algorithm. Based on the defect area location result and the Canny edge detection algorithm, the outline of the defect area is obtained, and the defect area and location information are calculated. According to the area, location and type information of the defect area, combined with the defect combination complexity analysis results, a defect severity assessment model is constructed. The defect combination complexity analysis is quantified by combining the spatial distribution, overlap degree and type combination of multiple defects. By establishing scoring rules, different defect combinations are given different weights, and the comprehensive score is calculated to obtain the defect severity assessment results; Based on the evaluation results, a dynamic threshold adjustment algorithm is adopted to adjust the defect judgment threshold according to the production batch and product type, and the threshold parameters are dynamically updated by analyzing historical data and current production conditions.
2. The method according to claim 1, wherein: The deep learning convolutional neural network is used to extract features from the textile image, and the texture, color and shape features of the textile surface are extracted through multi-layer convolution and pooling operations to obtain a feature map containing defect information, including: Acquire a textile image, and use a ResNet50 convolutional neural network to extract texture, color, and shape features of the surface of the textile image to obtain a feature map containing defect information; Performing image segmentation processing according to the feature map, dividing the feature map into a plurality of regions by using an Otsu algorithm, each region representing a local feature of the textile surface; For each of the plurality of regions, a gray level co-occurrence matrix, a color histogram and a color moment are calculated to construct a feature vector of the local region of the textile, wherein the feature vector reflects the fine structure, statistical characteristics and color distribution of the texture in the region; The feature vector is classified by using a random forest algorithm, and if the feature vector meets a preset normal region condition, it is determined to be a normal region; If the feature vector meets the preset defect area condition, it is determined to be a defect area; Performing morphological operations on the classification results to remove noise and obtain a distribution map of textile surface defects, wherein the distribution map marks the location and type of the defects; The defect distribution map is superimposed on the textile image to generate a visualization result showing the distribution of defects on the textile surface.
3. The method according to claim 1, wherein: According to the extracted defect feature map, feature maps of different scales are fused to extract multi-scale defect features and comprehensively describe the spatial distribution and combination information of defects, including: The defect feature map is transformed into a multi-scale image using a pyramid pooling operation to obtain a feature pyramid containing four levels. For each layer of feature maps in the feature pyramid, multi-scale convolution kernels are used in parallel to extract features to obtain defect texture and shape information of different scales; Adaptively weighting and fusing the multi-scale features according to the feature channel attention mechanism, and obtaining the importance weight of each feature channel through global average pooling and full connection layer processing; Performing non-maximum suppression processing on the fused feature map, if the search window size is 5x5 and the threshold is 0.5, retaining the local maximum response point; The area ratio and concentration of the defect area are calculated to determine the spatial distribution of the defects and the quantitative description of the combined information.
4. The method according to claim 1, wherein: The hierarchical clustering algorithm is used to perform fine-grained classification on multi-scale defect features, and by calculating the similarity between defect features, defects with similarity greater than a preset threshold are clustered into the same category to obtain defect classification results, including: According to the multi-scale defect features, the similarity matrix between the defect features is calculated to obtain the similarity value; Set a similarity threshold, classify defect features with similarity greater than the threshold into the same category, and form a preliminary classification result; The minimum distance method is used to calculate the distance between each category and generate a category distance matrix; According to the category distance matrix, the categories with distances less than the set value are merged and the defect classification results are updated; By calculating the coordinates of the center points of each category, the central feature vector of each category is obtained; Determine the distance between each central feature vector. If the distance is less than the set threshold, the corresponding categories will be merged. According to the merged categories, the defect classification results are updated to obtain fine-grained multi-scale defect classification; A voting mechanism is used to classify each defect feature and determine the fine-grained category to which it belongs; According to the defect feature distribution of fine-grained categories, the feature template of each category is generated to complete the fine-grained classification of multi-scale defects.
5. The method according to claim 1, wherein: In view of the situation where multiple defects exist at the same time, a multi-task learning model is constructed to simultaneously perform defect detection, classification and positioning tasks, and a back propagation algorithm is used to optimize the multi-task learning model, including: Acquire a textile image and extract multi-scale features of the textile image using a residual network structure to obtain a feature map containing defect information; Constructing three task branches according to the feature graph, wherein the three task branches are respectively used for defect detection, defect classification and defect location; Generate a multi-task loss function for the three task branches, wherein the multi-task loss function includes a defect detection loss, a defect classification loss, and a defect location loss; Determine a comprehensive loss function by adjusting a weight coefficient, wherein the comprehensive loss function is composed of a weighted combination of the defect detection loss, the defect classification loss, and the defect location loss; The back propagation algorithm is used to optimize the multi-task learning model. If the parameters of the multi-task learning model need to be updated, the Adam optimizer is used to update the parameters of the multi-task learning model.
6. The method according to claim 1, wherein: The method of using an image segmentation algorithm to locate the defect area, obtaining the contour of the defect area according to the defect area location result and by using a Canny edge detection algorithm, and calculating the defect area and position information includes: A fully convolutional network with a U-Net structure is used to perform pixel-level segmentation on the textile image to obtain a segmentation prediction map; Constructing a spatial attention module according to the segmentation prediction map, compressing the feature map in channel dimension, and obtaining the attention weight of the spatial dimension; Multiplying the attention weight by the segmentation prediction map to obtain an optimized defect area positioning result; According to the defect area positioning result, the outline of the defect area is extracted by using the Canny edge detection algorithm, and the outline is optimized by opening and closing operations to obtain the boundary of the defect area; Calculating the defect area according to the boundary of the defect area, wherein the defect area is obtained by counting pixels; The central coordinates of the defect area are calculated using the central moment, and the shape characteristics of the defect are described using the Hu invariant moment; If the intersection-over-union ratio of the segmentation result is greater than a preset threshold and the Dice coefficient is greater than a preset threshold, it is determined that the segmentation result is reliable.
7. The method according to claim 1, wherein: The defect severity assessment model is constructed based on the area, location and type information of the defect area and the defect combination complexity analysis results. The defect combination complexity analysis is quantified by combining the spatial distribution, overlap degree and type combination of multiple defects. By establishing scoring rules, different defect combinations are given different weights, and the comprehensive score is calculated to obtain the defect severity assessment results, including: Obtain the area, location and type information of the defect area and build a defect basic attribute data set; Calculate the defect combination complexity based on the spatial distribution, overlap degree and type combination of defects; The defect severity assessment model is constructed using defect basic attribute data set and defect combination complexity; By establishing scoring rules, different weights are assigned to different defect combinations and the comprehensive score is calculated; Based on the comprehensive score, the severity assessment result of the defect is obtained; If the defect severity assessment result exceeds the preset threshold, the defect alarm mechanism is triggered; Generate defect analysis report based on defect severity assessment results and defect alarm mechanism; Transmit defect analysis reports to the quality management system and update the defect database; According to the updated defect database, the defect severity assessment model and scoring rules are optimized.
8. The method according to claim 1, wherein: Based on the evaluation results, a dynamic threshold adjustment algorithm is used to adjust the defect determination threshold according to the production batch and product type, and the threshold parameters are dynamically updated by analyzing historical data and current production conditions, including: Obtain defect assessment results for different production batches and product types, calculate the average severity and standard deviation of each type of defect using the exponentially weighted moving average method, and obtain statistical indicators that reflect batch and product characteristics; According to the statistical indicators, the defect assessment results and production parameters of the current production batch are obtained once an hour, including defect type distribution, severity distribution and production environment data, and the data is stored in a time series database; Using a sliding window algorithm, combining the statistical indicators and the data in the time series database, to calculate a dynamic threshold adjustment factor; If the dynamic threshold adjustment factor has been calculated, then New_Threshold=Base_Threshold*(1+Adjustment_Factor) formula, to obtain the defect determination threshold adapted to the current production situation, where New_Threshold is the new threshold, Base_Threshold is the basic threshold, Adjustment_Factor is the adjustment factor; It is determined whether the production environment data exceeds a preset range. If so, an alarm is triggered and the defect determination threshold is suspended, and a preset fixed threshold is used for determination.
Citation Information
Patent Citations
Semi-supervised industrial product flaw detection method and system based on positive sample learning
CN112801962A
Textile defect detection method based on deep learning
CN115511796A
Fabric defect detection model establishment method and fabric defect detection method
CN115661022A
Apparatus and method for locating a moving object based on GNSS and notifying dangerous accidents
KR1020250054400A
Cited By
Stone layout intelligent warehouse management method and system based on machine vision
CN119648117A
Method and system for automatically detecting surface flaws of printed matter by utilizing machine vision
CN119804464A
Photovoltaic cell panel AI flaw detection method and device
CN119850601A
Textile state detection and analysis system
CN119887788A
A textile state detection and analysis system
CN119887788B