A monochromatic cloth defect detection method based on weakly supervised learning

Through a method based on weak supervision learning, a normal image feature library is established and the fabric defect detection is detected using the K nearest neighbor algorithm and anomaly threshold TH, which solves the problem of insufficient detection speed and accuracy in the prior art, and realizes efficient and real-time monochrome fabric defect detection.

CN115205209BActive Publication Date: 2025-07-22ZHEJIANG UNIV OF TECH

Patent Information

Application Number
CN202210595197.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-28
Publication Date
2025-07-22
Estimated Expiration
2042-05-28

AI Technical Summary

Technical Problem

The existing cloth defect detection methods have shortcomings in detection speed and accuracy, especially in complex textures, and rely on low manual detection efficiency and high error detection rate.

Method used

Using a method based on weakly supervised learning, a cloth image is acquired through preprocessing, a normal image feature library is established, and features are extracted using the pre-trained Resnet-18 network, and defect detection is performed by combining the K nearest neighbor algorithm and the abnormal threshold TH, and defect areas are obtained by segmenting the abnormal threshold.

Benefits of technology

The inspection rate and detection sensitivity of monochrome cloth defect detection are improved, the dependence on manual detection is reduced, and real-time and efficient defect detection is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115205209B_ABST
    Figure CN115205209B_ABST
Patent Text Reader

Abstract

The present invention relates to a monochromatic cloth defect detection method based on weakly supervised learning. By collecting the original cloth images and performing preprocessing, a normal image feature library is established; based on the normal image feature library, the abnormal threshold TH is set, the features of the processed image to be detected are extracted, and the K nearest neighbor algorithm is used to retrieve the K flawless image with the closest similarity to the image to be detected in the normal image dataset, and the K abnormal score between the TH flawless image and the image to be detected is calculated; threshold segmentation is performed using the abnormal threshold to obtain the segmentation mask image of the abnormal area corresponding to the cloth defect. The detection of the present invention is more targeted, has a higher recall rate for cloth image defects, does not require a large amount of time for dataset production and model training, and improves the detection sensitivity for small defect targets while ensuring the real-time performance of detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of general image data processing or generation, and belongs to the application of machine learning and machine vision technologies in the textile industry. In particular, it relates to a method for detecting monochromatic cloth defects based on weakly supervised learning. Background Art

[0002] With the development of social economy and science and technology, the competition in the textile industry has become increasingly fierce. The quality of cloth has a huge impact on the benefits of textile production. Major textile production enterprises are facing the dual pressures of high-quality standards and high labor costs. The quality inspection of cloth is an important link in the textile industry to control product quality and occupies an important position in the cloth production process.

[0003] At present, the vast majority of textile enterprises still use manual labor to inspect the quality of finished or semi-finished cloth, including the detection of cloth defects. Cloth defect detection is a series of simple but repetitive and boring operations. Under traditional manual inspection, the detection speed is usually about 15 - 20 m / min, and the efficiency of the entire production process is relatively low. Moreover, long-term work will cause visual fatigue in workers, which will greatly reduce the accuracy and efficiency of defect detection. Relevant statistical data shows that the false detection rate of human eyes for cloth defect detection can be as high as over 30%.

[0004] How to reduce the participation of manual labor in the cloth inspection process, improve the detection accuracy and speed is an urgent problem to be solved in current cloth defect detection. With the rapid development of integrated circuit technology, optical technology, digital image processing technology and deep learning technology in recent years, machine vision has been more and more widely used in the field of industrial surface defect detection, and the automatic detection of cloth defects has become an inevitable trend.

[0005] For an automatic cloth defect detection system, the core part is the defect detection method. Existing methods are mainly divided into several categories such as statistical analysis, frequency domain analysis, model analysis, learning analysis, etc.

[0006] The histogram analysis method in digital image processing technology can intuitively display the statistical law of image pixel values and has a relatively low calculation cost. Zhang et al. detected defects by comparing the histogram differences between defective and normal fabric images (see Zhang W Y, Zhang J, Hou Y, et al. MWGR: A new method for real-time detection of cord fabric defects. International Journal of Advanced Mechatronic Systems, 2012: 458-461). Although this method is simple and fast, it has the problem of low detection accuracy.

[0007] Common frequency domain analysis methods in image processing include Gabor filtering, wavelet transform, etc. Karlelar et al. proposed a fabric texture detection method combining wavelet transform and image morphology methods (see Karlekar V V, Biradar M S, Bhangale K B. Fabric Defect Detection Using Wavelet Filter. IEEE International Conference on Computing Communication Control and Automation, 2015: 712-715), achieving good results.

[0008] Normal sample learning is the most commonly used unsupervised learning method for surface defect detection. Hu et al. proposed an unsupervised method for automatically detecting fabric defects based on a deep convolutional generative adversarial network (see Hu G H, Huang J F, Wang Q H, et al. Unsupervised fabric defect detection based on a deep convolutional generative adversarial network. Textile Research Journal, 2020, 90(3-4): 247-270). By introducing an encoder into the standard DCGAN, the reconstruction of the detected image is realized. When the reconstructed image is subtracted from the original image, a residual map highlighting the defective area is obtained. However, when the image background changes are complex, the effect of this method will be greatly reduced.

[0009] The patent with the application number 202110765759.9 discloses a device and method for detecting fabric surface defects based on machine vision. This method uses an area array camera to capture an image of a defect-free fabric as a standard sample, calculates a flat-field correction matrix based on the standard sample to achieve brightness compensation, and uses the principle of the mean clustering algorithm to calculate the clustering center and other characteristic parameters of the standard sample. It calculates the Euclidean distance from the pixels of the image to be measured to the clustering center and determines whether there are defects according to a threshold. Although this method uses a flat-field correction matrix to achieve brightness compensation for the fabric image and improves the detection effect to a certain extent, the model established by this method is too simple, and it is difficult to achieve satisfactory results in actual application scenarios where the texture of the fabric is relatively complex.

[0010] The patent with the application number 202110568000.1 discloses a fabric defect detection model and method based on improved YOLOv4-tiny. This detection model adds a dense connection convolutional block CSPDenseBlock to the residual block of the YOLOv4-tiny backbone network and adds an spp module at the end of the backbone network to form a new feature extraction network. The new feature extraction network outputs two feature maps of different scales. The two feature maps of different scales are respectively processed by their corresponding convolutional blocks and then enter their respective YOLO layers to predict the target. Although this method uses the YOLOv4-tiny network with fewer layers for improvement, the detection speed is relatively fast and the accuracy is also improved compared with the conventional model, but the actual detection process is complex and the generalization ability of the model remains to be tested. Summary of the Invention

[0011] The present invention solves the problems existing in the prior art and provides an optimized method for detecting defects of single-color fabrics based on weakly supervised learning, which can detect the defect conditions of various types of single-color dyed fabrics in real time.

[0012] The technical solution adopted by the present invention is a method for detecting defects of single-color fabrics based on weakly supervised learning, and the method includes the following steps:

[0013] Step 1: Collect the original fabric image and perform preprocessing;

[0014] Place the fabric to be measured flat on a transmission type fabric inspection device, and use a stretching device to ensure that the fabric is completely flat when passing through the field of view of the line array camera of the inspection device. The inspection device is composed of a line array camera, an LED line light source and a fixed bracket. The inspection device is a conventional technology in the art, and those skilled in the art can set it according to their needs. Generally, a line array camera and an LED line light source are set on the fixed bracket.

[0015] Step 2: If the normal image feature library for the corresponding category of the current piece of cloth already exists, proceed to the next step; otherwise, screen the image processed in Step 1, select several flawless images as the normal image dataset, and establish a normal image feature library.

[0016] In the present invention, for cloth defect detection, the normal image features without defects are required as a reference. If the normal image feature library for the current cloth category already exists, directly jump to the next step; otherwise, first manually screen the preprocessed image obtained in Step 1 to obtain N flawless images as the normal image dataset. Generally, the value range of N is [10, 100]. Since the proportion of cloth defects in the actual printing and dyeing production line is generally low, and the output of a single type of cloth is large, it can be quickly completed by manually screening a small number of flawless images for each type of cloth produced.

[0017] In the present invention, after obtaining the normal image dataset, use the pre-trained convolutional neural network model to extract the features of each normal image and form a normal image feature library. When a feature extraction network is needed to extract the features of a certain type of specific target object, self-supervised feature learning is often used, that is, learning features from scratch on the input target object image. However, in the case of a relatively small amount of sample data, the feature extraction network trained using the cloth image dataset cannot well obtain the target object features. The research of Bergman et al. (see Bergman L, Hoshen Y. Classification-Based Anomaly Detection for General Data. ICLR, 2020, pp. 1 - 10) also shows that the features extracted by the self-supervised network perform worse in defect detection than the features extracted by some network models pre-trained on large public datasets. Based on this, select the Resnet-18 network model pre-trained on the ImageNet dataset as the feature extractor for the normal image dataset. Input each normal image into the Resnet-18 network model, and save the high-dimensional feature vector output by the average pooling layer and the low-dimensional feature map output by the first residual block to form the normal image feature library for the current cloth category.

[0018] In the present invention, the normal image feature library includes a high-dimensional feature vector set F NH and a low-dimensional feature map set F NL .

[0019] Step 3: Determine the anomaly threshold TH based on the normal image feature library.

[0020] In the present invention, the normal image feature library has been obtained in step 2. In order to correctly distinguish the abnormal pixels with defects in the image to be detected in the subsequent steps, it is necessary to find the statistical law of the similarity between the low-dimensional feature image pixels of the normal image, that is, to find an "abnormal threshold" to determine whether each pixel is normal.

[0021] Step 4: Extract the features of the image to be detected processed in step 1;

[0022] In the present invention, the pre-trained Resnet-18 network model used in step 2 is used to extract the features of the image to be detected B. Similarly, the high-dimensional feature vector f BH output by the average pooling layer and the low-dimensional feature map f BL output by the first residual block are recorded. Among them, the image to be detected is the cloth image after preprocessing in step 1.

[0023] Step 5: Adopt the K-nearest neighbor algorithm to retrieve the K flawless images with the closest similarity to the image to be detected in the normal image dataset;

[0024] In the present invention, the similarity of the images here is measured by calculating the Euclidean distance between the set F NH of the high-dimensional feature vectors of the normal images obtained in step 2 and the high-dimensional feature vector f BH of the image to be detected obtained in step 4.

[0025] In the present invention, in the usual classification tasks, the image can be marked as normal or abnormal in this step, that is, by verifying whether the average value of the Euclidean distances between the feature vectors of the image to be detected and the K nearest flawless images is greater than a certain threshold to determine. However, in the cloth defect detection task, the above conclusion does not necessarily hold; when the resolution of the cloth sample is very high, if the defects in the image are very small or very light, then these defects have little impact on the high-dimensional features of the entire image. Based on the above analysis, a set of low-dimensional feature maps of the K nearest flawless images of the image to be detected B is established, denoted as F KL .

[0026] Step 6: Calculate the abnormal scores between the K flawless images and the image to be detected;

[0027] In the present invention, the abnormal degree of each pixel position is determined by calculating the pixel-level image abnormal score.

[0028] Step 7: Use the abnormal threshold TH for threshold segmentation to obtain the segmentation mask image of the abnormal area corresponding to the cloth defect.

[0029] In the present invention, the abnormal score map obtained in step 6 reflects the degree of abnormality at each pixel position on the cloth image to be detected. The larger this value is, the greater the possibility of cloth defects at that pixel. Therefore, the abnormal score map obtained in step 6 is binarized using the abnormal threshold TH calibrated in step 3 to obtain a segmentation mask image of the abnormal area in the image to be detected.

[0030] Preferably, in step 1, the original cloth image is acquired by a line array camera. The camera collects the gray values of each pixel point in each row, and a complete original image is generated when the number of rows reaches the set vertical resolution.

[0031] In the present invention, the position, focal length, and line resolution of the line array camera are set. The camera inputs the gray values of each pixel point in each row collected into a processing computer, and a complete original image is generated when the number of rows reaches the set vertical resolution.

[0032] Preferably, first, an original cloth image with a resolution of W×H is acquired, and then the resolution of the original cloth image is reduced to (W / 2)×(H / 2) using the Lanczos interpolation method, that is, preprocessing is performed by reducing both the horizontal and vertical directions to half of the original image. The value range of W is [2000, 8000], and the value range of H is [1000, 4000].

[0033] Preferably, step 3 includes the following steps:

[0034] Step 3.1: If the abnormal threshold TH has been calculated for the type of the current cloth, directly proceed to step 4; otherwise, proceed to the next step.

[0035] Step 3.2: Randomly select 1 normal image A from the normal image feature library, and denote its low-dimensional feature map as f AL , and then randomly select X normal images from the remaining normal image feature library, and denote them as the low-dimensional feature map set F XL ; Calculate the average Euclidean distance at each pixel position on the feature map between the low-dimensional feature map set F XL and the low-dimensional feature map f AL according to formula (1).

[0036]

[0037] Among them, p represents each pixel position on the feature map, and f AL (p) represents the feature value of the low-dimensional feature map f AL at the p position. The value range of X is [0.2×N, 0.6×N], where N is the number of images in the normal image data set; use d normal Each pixel value in the figure represents the feature maps of these normal images and f ALThe similarity at each pixel position, the smaller the value, the higher the similarity;

[0038] Step 3.3: After repeating Step 3.2 M times, the M calculated d normal The double of the mean value of all pixels in the figure is set as the anomaly threshold TH. The value range of M is [3, 10].

[0039] In the present invention, d normal is the feature pixel distance map, representing the similarity between these normal image feature maps and f AL at each pixel position, the smaller the value, the higher the similarity; The value range of X is [0.2×N, 0.6×N].

[0040] In the present invention, after performing the above calculation M times, the distribution of these similarity data is statistically analyzed and found to be basically normally distributed, where the minimum value is close to zero and its mean is approximately equal to the mathematical expectation of the normal distribution. Therefore, the double of the mean value of all pixels in the M calculated d normal figure is set as the anomaly threshold TH, and the pixel positions in the feature pixel distance map higher than this threshold have obvious anomaly features.

[0041] Preferably, in Steps 2 and 4, the features of the image are extracted by a pre-trained Resnet-18 network model, and the high-dimensional feature vector output by the average pooling layer and the low-dimensional feature map output by the first residual block are recorded.

[0042] Preferably, in Step 6, for the image B to be detected, a set F KL of the low-dimensional feature maps of K nearest neighbor flawless images is taken, and the average Euclidean distance between the features of the image to be detected and the features of the K nearest neighbor flawless images is calculated at each pixel position of the low-dimensional feature map according to Equation (2),

[0043]

[0044] where p represents each pixel position on the feature map, f BL (p) represents the feature value of the low-dimensional feature map of the image to be detected at the p position, and d anomaly is the feature pixel distance map, representing the degree of difference between these flawless image feature maps and f BL at each pixel position, the larger the value, the greater the possibility of a fabric flaw at this pixel point.

[0045] Preferably, the feature pixel distance map is upsampled to the size of the original image by the bilinear interpolation method and smoothed using a Gaussian filter to reduce the sharp change in pixel values, and finally an anomaly score map with the same size as the image to be detected is obtained.

[0046] Preferably, in step 7, the anomaly score map is binarized with the calibrated anomaly threshold TH to obtain a segmentation mask image of the anomaly region in the image to be detected.

[0047] The present invention relates to an optimized monochromatic cloth defect detection method based on weakly supervised learning. By collecting the original cloth image and performing preprocessing, a normal image feature library is established; based on the normal image feature library, the anomaly threshold TH is calibrated, the features of the processed image to be detected are extracted, the K-nearest neighbor algorithm is used to retrieve the K flawless images with the closest similarity to the image to be detected in the normal image dataset, and the anomaly score between the K flawless images and the image to be detected is calculated; threshold segmentation is performed using the anomaly threshold TH to obtain a segmentation mask image of the anomaly region corresponding to the cloth defect.

[0048] The beneficial effects of the present invention are as follows: Using the features of flawless images of the same type of monochromatic cloth as a reference, the detection is more targeted, and the recall rate for cloth image defects is relatively high; Using a convolutional neural network model pre-trained on a large public dataset for image feature extraction, there is no need to spend a lot of time on dataset production and model training; Using the low-dimensional feature map of a lightweight model for anomaly score calculation, while ensuring the real-time performance of detection, the detection sensitivity for small defect targets is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 is a flowchart of the present invention.

[0050] Figure 2 is a schematic structural diagram of the cloth defect detection system of the present invention.

[0051] Figure 3 is the image to be detected in the present invention.

[0052] Figure 4 After adopting the method of the present invention, for Figure 3 cloth defect detection result diagram. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0053] The following further describes the present invention in detail with reference to embodiments, but the protection scope of the present invention is not limited thereto.

[0054] The present invention relates to a method for detecting defects on a single-color cloth based on weakly supervised learning. The technical concept is as follows: First, the completely flattened single-color cloth is driven by a transmission-type cloth inspection device to pass through the field of view of a line array camera. The original image of the cloth is collected by the line array camera and subjected to scaling preprocessing. Secondly, a batch of defect-free images are manually selected to form a normal image dataset, and a pre-trained convolutional neural network model is used to extract the low-dimensional feature map and high-dimensional feature vector of each image in the normal image dataset. Then, an anomaly threshold is obtained through pixel-level feature similarity calculation and statistical analysis. Next, the features of the image to be detected are extracted, and K nearest neighbor images are found by calculating the distance from the high-dimensional feature vector of each image in the normal image dataset. Then, the pixel distance between the feature map of the image to be detected and the corresponding feature maps of the K normal images is calculated as the anomaly score. Finally, a segmentation mask image of the abnormal area is obtained using the threshold segmentation method.

[0055] The implementation object of the defect detection of the present invention is various single-color dyed cloths. The selected processing platform is a combination of Intel i7-10750H, NVIDIA RTX 2070, and 16G RAM, and the operating system is Windows 10. The method of the present invention is implemented based on the deep learning framework Pytorch.

[0056] As Figure 1 shown, the present invention relates to a method for detecting defects on a single-color cloth based on weakly supervised learning, which is carried out according to the following steps:

[0057] (1) Collect the original image of the cloth and preprocess it;

[0058] (2) Establish a normal image feature library according to the cloth category;

[0059] (3) Set the anomaly threshold;

[0060] (4) Extract the features of the image to be detected;

[0061] (5) Search for the nearest neighbor images;

[0062] (6) Calculate the anomaly score;

[0063] (7) Threshold segmentation.

[0064] Step (1) specifically includes:

[0065] Place the cloth to be tested flat on the transmission-type cloth inspection device, and use the stretching device to ensure that the cloth is completely flat when passing through the field of view of the line array camera of the detection device. The schematic structural diagram of the cloth defect detection system is as Figure 2 shown. The detection device consists of a line array camera, an LED line light source, and a fixed bracket. The line array camera is fixed on the top of the detection device, and the LED light source is fixed in the middle of the detection device and placed obliquely.

[0066] Set the position and focal length of the line array camera, set the row resolution to 4096, and the camera inputs the gray values of each pixel point in each row collected into the processing computer. When the number of rows reaches 2160, a complete original image is generated. In order to retain the details of the cloth image as much as possible and ensure the real-time performance of detection, the present invention first collects the original cloth image with a resolution of 4096×2160, and then calls the Resize function in torchvision.transforms to scale the image to a resolution of 2048×1080, where the interpolation parameter is set to PIL.ANTIALIAS to call the Lanczos interpolation method, and smooth filtering is performed on the image during the scaling process.

[0067] Step (2) specifically includes:

[0068] If the normal image feature library of the current cloth category already exists, directly jump to the next step; otherwise, first manually screen the preprocessed image obtained in step (1) to obtain N (N = 40) flawless images as the normal image data set.

[0069] Select the Resnet-18 network model pre-trained on the ImageNet data set as the feature extractor for the normal image data set, and save the high-dimensional feature vector output by the average pooling layer and the low-dimensional feature map output by the first residual block to form the normal image feature library. The specific implementation method is as follows: First, convert each normal image into a tensor and perform normalization; then load the Resnet-18 pre-trained model, set the forward propagation hook at the position of the first residual block and the position of the average pooling layer; finally, send the image data into the model for inference calculation, and save the data in the hook to form the normal image feature library. This feature library includes the high-dimensional feature vector set F NH and the low-dimensional feature map set F NL .

[0070] Step (3) specifically includes:

[0071] If the abnormal threshold (denoted as TH) has been calculated for the current cloth type, jump to the next step, otherwise first randomly select a normal image A from the normal image feature library as a sample image; then randomly select X (X=10) normal images from the remaining normal image feature library as reference images; then call the torch.pairwise_distance function to calculate the Euclidean distance matrix of the sample image features and the image features of the 10 reference images at each pixel position on the low-dimensional feature map, and take the average of the first dimension of the Euclidean distance matrix to obtain the feature pixel distance map; then repeat the above three operations M (M=5) times to obtain 5 feature pixel distance maps, and calculate the mean of all pixels in them; finally, twice the mean is used as the abnormal threshold TH.

[0072] Step (4) specifically includes:

[0073] The present invention uses the same pre-trained Resnet-18 network model as step (2) to extract the features of the image B to be detected, and similarly uses the high-dimensional feature vector f output by the average pooling layer BH And the low-dimensional feature map f output by the first residual block BL The image to be detected is the cloth image after preprocessing in step (1), and steps (2) and (3) are skipped. Figure 3 shown.

[0074] Step (5) specifically includes:

[0075] Retrieve K (K=5) flawless images closest to the image to be detected from the normal image dataset. The image similarity here is calculated by calculating the high-dimensional feature vector set F of the normal image obtained in step (2) NH and the high-dimensional feature vector f of the image to be detected obtained in step (4) BH The specific implementation method is as follows: first, let the high-dimensional feature vector of the image to be detected calculate the Euclidean distance with each high-dimensional feature vector in the normal image feature library; then use the torch.topk function to get the top 5 data with the smallest distance value and their subscripts; finally, save the data and subscripts of the low-dimensional feature maps of the 5 normal images for use in subsequent steps.

[0076] Step (6) specifically includes:

[0077] Use K (K = 5) flawless images corresponding to one image to be detected, and calculate the average Euclidean distance between the features of the image to be detected and the features of the 5 flawless images for each pixel on the low-dimensional feature map. The specific implementation is as follows: First, call the torch.pairwise_distance function to calculate the Euclidean distance matrix between the features of the image to be detected and the features of the 5 flawless images at each pixel position on the low-dimensional feature map; then take the mean of the first dimension of the Euclidean distance matrix to obtain the feature pixel distance map; finally, upsample the feature pixel distance map to the size of the input image (2048×1080) using bilinear interpolation method, and smooth it using a Gaussian filter to reduce the sharp changes in the values, obtaining an anomaly score map with the same size as the image to be detected.

[0078] Step (7) specifically includes:

[0079] The anomaly score map obtained in step (6) reflects the degree of anomaly at each pixel position on the cloth image to be detected. The larger this value, the greater the possibility of cloth defects at that pixel. Use the anomaly threshold TH calibrated in step (3) to binarize the anomaly score map to obtain a segmentation mask image of the monochromatic cloth anomaly region. A partial region screenshot of the cloth defect detection result image is as Figure 4 shown.

[0080] Those skilled in the art should understand that the embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0081] The present invention is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in Figure 1 one or more flows or multiple flows and / or blocks Figure 1 one or more blocks or multiple blocks.

[0082] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce a manufacture including an instruction means that implements the function specified in one or more of the processes and / or blocks Figure 1 of the flow(s) or block(s). Figure 1

[0083] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable apparatus provide steps for implementing the function specified in one or more of the processes and / or blocks Figure 1 of the flow(s) or block(s). Figure 1

[0084] Although the preferred embodiments of the present invention have been described, additional changes and modifications can be made by those skilled in the art once they learn of the basic inventive concept. Therefore, the appended claims are intended to be construed to include the preferred embodiments as well as all changes and modifications that fall within the scope of the present invention.

[0085] It is obvious that those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these modifications and variations.​​

Claims

1. A monochromatic cloth defect detection method based on weakly supervised learning, characterized in that: The method includes the following steps: Step 1: Collect the original cloth image and perform preprocessing; Step 2: If the normal image feature library corresponding to the current cloth category already exists, proceed to the next step. Otherwise, screen the image processed in Step 1, select several flawless images as the normal image dataset, and establish the normal image feature library; Step 3: Determine the anomaly threshold TH based on the normal image feature library, including the following steps: Step 3.1: If the anomaly threshold TH corresponding to the current cloth type has been calculated, directly proceed to Step 4. Otherwise, proceed to the next step; Step 3.2: Randomly select one normal image A from the normal image feature library, and denote its low-dimensional feature map as f AL , and then randomly select X normal images from the remaining normal image feature library, and use them as a low-dimensional feature map set denoted as F XL ; Calculate the low-dimensional feature map set F XL and the low-dimensional feature map f AL at the average Euclidean distance at each pixel position of the feature map (1) Among them, p represents each pixel position on the feature map, and f AL (p) represents the feature value of the low-dimensional feature map f AL at the position p. The value range of X is [0.2×N, 0.6×N], where N is the number of images in the normal image dataset; in terms of d normal Each pixel value in the figure represents the similarity between these normal image feature maps and f AL at each pixel position, the smaller the value, the higher the similarity; Step 3.3: After repeating Step 3.2 for M times, set twice the mean value of all pixels of the M calculated d normal normal as the anomaly threshold TH; the value range of M is [3, 10]; Step 4: Extract the features of the image to be detected processed in Step 1. In Steps 2 and 4, use the pre-trained Resnet-18 network model to extract the features of the image, and record the high-dimensional feature vector output by the average pooling layer and the low-dimensional feature map output by the first residual block; Step 5: Use the K-nearest neighbor algorithm to retrieve the K flawless images with the closest similarity to the image to be detected in the normal image dataset; Step 6: Calculate the anomaly scores between the K flawless images and the image to be detected; Step 7: Use the anomaly threshold TH for threshold segmentation to obtain the segmentation mask image of the anomaly area corresponding to the cloth defect.

2. The monochromatic cloth defect detection method based on weak supervision learning according to claim 1, wherein: In the above Step 1, the original cloth image is acquired by a line array camera. The camera collects the gray values of each pixel point in each row, and a complete original image is generated when the number of rows reaches the set vertical resolution.

3. A monochromatic cloth defect detection method based on weakly supervised learning according to claim 2, characterized in that: First, collect the original cloth image with a resolution of W×H, and then use the Lanczos interpolation method to scale it to a resolution of (W / 2)×(H / 2). The value range of W is [2000, 8000], and the value range of H is [1000, 4000].

4. A monochromatic cloth defect detection method based on weakly supervised learning according to claim 1, characterized in that: In the said step 6, for the image B to be detected, a set F of low-dimensional feature maps of K nearest neighbor flawless images is taken KL , and the average Euclidean distance between the features of the image to be detected and the features of the K nearest neighbor flawless images is calculated at each pixel position of the low-dimensional feature map according to formula (2). (2) Among them, p represents each pixel position on the feature map, and f BL (p) represents the feature value at the p position of the low-dimensional feature map of the image to be detected. d anomaly is the feature pixel distance map, representing the difference degree between these flawless image feature maps and f BL at each pixel position. The larger the value, the greater the possibility of cloth defects at that pixel position.

5. The monochromatic cloth defect detection method based on weak supervision learning according to claim 4, characterized in that: Upsample the feature pixel distance map to the size of the original image using the bilinear interpolation method, and perform smoothing processing using a Gaussian filter to reduce the sharp changes in pixel values, finally obtaining an anomaly score map with the same size as the image to be detected.

6. The monochromatic cloth defect detection method based on weak supervision learning according to claim 1, characterized in that: In the above Step 7, binarize the anomaly score map with the determined anomaly threshold TH to obtain the segmentation mask image of the anomaly area in the image to be detected.

Citation Information

Patent Citations

  • Fabric Defect Detection Method Based on Improved YOLOv4-tiny

    CN113177937B

  • Cloth surface defect detection device and method based on machine vision

    CN113777030A

  • A cloth defect detection method based on Fourier transform and image morphology

    CN109934802A

  • Feature matching-based fabric abnormal region detection method

    CN113554605A

Cited By

  • An image detection method, system, device and medium for minor defects in fabrics

    CN122676266A