Weakly supervised learning based image detection method for hairiness defects
By combining weakly supervised learning and the U-Net model, the problem of poor label consistency in the detection of fuzz defects in chemical fiber spindles is solved, achieving high-accuracy automated detection, adapting to complex working conditions and fuzz of different shapes, and reducing costs.
Patent Information
- Application Number
- CN202310055343.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-18
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2043-01-18
AI Technical Summary
In existing technologies, the detection of fuzz defects in chemical fiber spindles relies on manual labeling, which suffers from problems such as weak consistency of dataset labels and limited performance of deep learning models. In particular, the fuzz defects do not have a fixed shape, resulting in large errors in the detection results.
Weakly supervised learning is adopted, and the U-Net model is pre-trained and weakly supervised. The labels are adjusted by combining DenseCRF and confidence threshold, and the weak labels are gradually optimized. Gradient algorithm is used to extract the edge of the spindle, reducing the computational load of the detection model and improving the detection accuracy.
It achieves high accuracy in detecting fuzz under complex working conditions, reduces hardware costs, avoids errors introduced by manual labeling, adapts to fuzz defects of different shapes, and achieves a detection accuracy of 94.55%.
Smart Images

Figure CN115908423B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of textile technology, the field of deep learning-based defect detection technology, and particularly to a method and acquisition device for detecting fuzz defects on the surface of chemical fiber spindles based on weakly supervised learning. Background Technology
[0002] The chemical fiber industry is China's earliest-developed traditional manufacturing sector, boasting the most independent core technologies and the highest degree of industrialization. As a highly process-oriented industry, it is characterized by consistent processes and a high degree of standardization. However, in stark contrast to the automation of production processes, the quality inspection of finished chemical fiber spindles still relies heavily on manual labor. Defects such as fuzzy fibers in finished spindles, once entering downstream textile production, directly lead to flawed fabrics. Compared to other industrial products, defects in chemical fiber products are characterized by their diversity, varying dimensions, and complex background textures. These issues make real-time defect detection a crucial and scientifically significant challenge in the chemical fiber production process.
[0003] Fuzzy defects on a yarn spindle are strip-shaped or clump-shaped defects of varying lengths and shapes extending from the end face of the spindle. The color of the fuzz is the same as that of the spindle. The causes of fuzz include, but are not limited to, improper setting of yarn output process parameters, mechanical factors, and human factors. Fuzzy defects can cause accidents such as warp breakage in warp knitting machines, as well as defects such as uneven fabric surface, pilling, and fuzzing in the downstream weaving process. Therefore, fuzzy defect detection is of great significance in the chemical fiber production process.
[0004] Existing patents, such as the method and grading method, storage medium and device for detecting and classifying defects in the appearance of silk spindles (CN114299065B), use deep learning models to detect defects in silk spindles. The deep learning models mentioned are all trained based on supervised learning algorithms. However, compared to traditional target detection, silk spindle defects do not have a fixed shape. Therefore, when designing the training dataset for the deep classifier, there is a problem of large intra-class variance. Furthermore, fuzzy defects have small pixel scales and edges are blurred due to ghosting and defocusing. When manually labeling fuzzy defects, there are inconsistencies in judgments among different labelers and inconsistent standards for different defects, leading to weak label consistency in the dataset. These problems directly limit the performance of the trained deep learning model, resulting in errors in the final detection results. In the method, device, electronic device and storage medium for detecting surface defects in chemical fiber spindles (CN 113344923 B), labels generated by traditional image processing algorithms are used to train a deep convolutional network. This method uses image processing algorithms to generate highly consistent mask labels, and the model trained under these labels performs exceptionally well. However, fuzzy defects have no fixed shape and are more complex than strip-shaped strands. The slope-based judgment method proposed in this patent cannot correct misjudged or missed fuzzy defect labels. Therefore, its proposed mask dataset generation method fails for fuzzy defects. Establishing a fuzzy defect training set with sufficient samples and reliable labels is of great significance but also extremely difficult for deep models under the supervised learning paradigm. Summary of the Invention
[0005] The purpose of this invention is to address the practical problems of large data requirements and low quality of manual labels in the detection of appearance defects of silk spindles based on deep learning technology, and to propose a weakly supervised paradigm for detecting appearance defects of chemical fibers.
[0006] Therefore, the present invention adopts the following technical solution:
[0007] A method for detecting hair defects in images based on weakly supervised learning, characterized by the following steps:
[0008] Step 1: Obtain the original image of the spindle product to be inspected;
[0009] Step 2: Use an algorithm to segment the original image and obtain mask annotations;
[0010] Step 3: Construct a pre-training dataset using the original images and mask annotations;
[0011] Step 4: Pre-train the U-Net model using the pre-training dataset to obtain the pre-trained model;
[0012] Step 5: Perform weakly supervised training on the pre-trained model obtained in Step 4 to obtain a weakly supervised trained model;
[0013] The pre-training data label set obtained in step three is used as the initial label for weakly supervised training; weakly supervised training is performed in a fixed number of rounds, with each round containing steps in the following sequence:
[0014] Each round of weakly supervised training consists of two steps: weak label update and network parameter update, which are performed alternately throughout the training process. First, weak label update is performed by using the U-Net model to infer from the training set samples, obtaining the probability map Y directly predicted by the U-Net model. Then, DenseCRF is used to adjust the probability map Y, resulting in probability map Y′. Based on a confidence threshold T, pixels in probability map Y′ with probability values less than T are labeled as background, and the remaining pixels are labeled as hair, resulting in a labeled map L′. Finally, the original labeled map L is replaced with labeled map L′. Next, network update is performed, using the original sample images and the updated labeled map L to train the U-Net network. After both steps are completed, the performance of the model obtained in this round is tested using test set data, and the test results and model parameters are saved.
[0015] After weakly supervised training is completed, retain the parameter set with the highest accuracy based on the model and test results obtained during the weakly supervised training process;
[0016] Step 6: Input the sample to be detected into the weakly supervised training model for inference to obtain the hair segmentation image in the sample;
[0017] Step 7: Organize the hair segmentation image to obtain defect information in the sample;
[0018] Step 8: Output defect information.
[0019] In a preferred embodiment, prior to step one, a detection device is constructed, the detection device comprising the following modules:
[0020] The spindle conveying module is used to deliver and remove spindles to and from the shooting station;
[0021] The spindle position determination module is used to capture events of the spindle passing through the shooting station;
[0022] The image acquisition module is used to acquire images of the wire spindle at the camera station;
[0023] The image information maintenance module is used to determine the source spindle of the acquired image;
[0024] The control module is used to integrate sensor signals and implement control.
[0025] In a preferred embodiment, step one includes the following process:
[0026] The spindle conveying module can be a roller conveyor. The spindle to be tested is placed on a tray inside the roller conveyor of the spindle conveying module; the roller conveyor transports the spindle past the shooting station to trigger a signal;
[0027] The control module receives and responds to the trigger signal, and performs the following operations in sequence: controls the image information maintenance module to output the spindle number at the current shooting station, controls the light source in the image acquisition module to illuminate, and controls the camera in the image acquisition module to capture images;
[0028] The camera outputs an image.
[0029] In a preferred embodiment, step two includes the following steps:
[0030] Step 2.1: Filter the original image using Gaussian filtering, median filtering, and mean filtering to obtain a denoised image;
[0031] Step 2.2: Use the Canny algorithm to extract the spindle edge map and the hair edge map from the denoised image;
[0032] Step 2.3: Remove the spindle edges from the fuzz edge map based on the spindle edge map to obtain the fuzz edge map;
[0033] Step 2.4: Perform morphological closing operations on the hair edge image to obtain hair mask annotations.
[0034] In a preferred embodiment, step three includes the following steps:
[0035] Step 3.1: Using the edge of the silk spindle as the center of the window, slide the window to capture an image block;
[0036] Step 3.2: Calculate the sum of gray values of all image blocks, and remove image blocks that do not contain spindles based on the sum of gray values to obtain the pre-training dataset.
[0037] In a preferred embodiment, step five includes the following steps:
[0038] Step 5.1: Determine that the pre-training data label set obtained in Step 3 will be used as the initial label for weakly supervised training;
[0039] Step 5.2: Perform weakly supervised training on the pre-trained model;
[0040] Step 5.3: Based on the model obtained during the weakly supervised training process and the test results, select the model with the best performance as the final detection model.
[0041] Further, in a preferred embodiment, step 5.2 includes the following steps:
[0042] Step 5.2.1: Use the U-Net model to infer the training set samples to obtain the probability map Y predicted by the U-Net model;
[0043] Step 5.2.2: Use DenseCRF to adjust the probability map Y to obtain the probability map Y′;
[0044] Step 5.2.3: Based on the confidence threshold T, mark the pixels in probability map Y′ with a probability less than T as background and mark the remaining pixels as foreground to obtain the label map L′. Replace the original label map L with the label map L′.
[0045] Step 5.2.4: Train the U-Net network using the original sample image and the updated labeled image L;
[0046] Step 5.2.5: Test the model obtained in this round of training, and retain the test results and model parameters.
[0047] In a preferred embodiment, step six includes the following steps:
[0048] Step 6.1: Using the image patch extraction method employed in Step 3, extract image patches from the image to be detected to obtain the sample to be detected;
[0049] Step 6.2: Input all samples to be detected into the final detection model for inference to obtain the prediction map.
[0050] In a preferred embodiment, step seven includes the following steps:
[0051] Step 7.1: Generate a blank mask image based on the original image size;
[0052] Step 7.2: Restore the mask image in the segmented image to the blank mask image according to the position of the sample in the original image, and obtain the overall segmentation image containing the segmentation information of all samples in the image;
[0053] Step 7.3: Perform morphological closing operation on the overall segmentation image to obtain a continuous hair mask image;
[0054] Step 7.4: Use a contour detection algorithm to extract the contour of each hair block, label the contours and calculate the area of the hair block within each contour;
[0055] Step 7.5: Sort the fuzzy blocks according to their area size, and count the number of fuzzy blocks and bounding box information for different area ranges.
[0056] The technical solutions provided by the examples disclosed in this invention may include the following beneficial effects:
[0057] Due to the complex working conditions in industrial settings, images often exhibit distortions such as motion blur and out-of-focus artifacts, making it difficult to generate consistent labels for manually labeled wool images. This method abandons the supervised learning paradigm and introduces a weakly supervised learning approach. It trains a deep convolutional model using weak labels, automatically optimizing errors in the weak labels during training. This avoids the inconsistency issues easily introduced by manually labeling small, out-of-focus targets with motion blur. The gradual correction of weak labels during training improves detection accuracy. Based on the morphological characteristics of wool, a gradient algorithm is used to extract the edges of the wool spindles, extracting samples to be detected within areas where spindles may exist. This reduces the computational load of the detection model, improves algorithm speed, and lowers hardware costs. This invention overcomes the problems of high cost, high error rate, and inaccurate grading associated with manual detection in existing technologies, as well as the low model accuracy caused by inaccurate labels in deep supervised learning algorithms. Attached Figure Description
[0058] Figure 1 This is a sample image of a silk spindle according to an embodiment of the present invention;
[0059] Figure 2 This is a flowchart illustrating an embodiment of the present invention;
[0060] Figure 3A This is a schematic diagram of the process in step 3 of the present invention, specifically including the hair, the filament, and the texture edge diagram;
[0061] Figure 3B This is a schematic diagram of the process in step 3 of the present invention, specifically including a diagram of the edge of the wire spindle;
[0062] Figure 3C This is a schematic diagram of the process in step 3 of the present invention, specifically showing only the edge diagram of the hair;
[0063] Figure 3D This is a schematic diagram of the process in step 4 of the present invention, specifically a schematic diagram of a sliding window along the edge of the spindle;
[0064] Figure 4 This is an overall architecture diagram of the improved U-Net according to an embodiment of the present invention;
[0065] Figure 5 This is a flowchart of the weakly supervised training process according to an embodiment of the present invention;
[0066] Figure 6 This is a schematic diagram of the detection device according to an embodiment of the present invention. In the figure, there is a roller conveyor 100, a position sensor 200, a tray 301, a spindle 302, a light source 401, a camera 402 and its imaging system, and a radio frequency identification sensor 500. Detailed Implementation
[0067] To enable those skilled in the art to better understand the technical solutions of the present invention, preferred embodiments of the present invention are described below in conjunction with specific examples. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote elements with the same or similar functions throughout. However, it should be understood that the drawings are for illustrative purposes only and should not be construed as limiting the present invention. To better illustrate this embodiment, some parts in the drawings may be omitted, enlarged, or reduced, and do not represent the actual product size. It is understandable for those skilled in the art that some well-known structures and their descriptions may be omitted in the drawings. The positional relationships described in the drawings are for illustrative purposes only and should not be construed as limiting the present invention.
[0068] In the technical solution of this invention, the specific application scenarios for the appearance inspection of the silk spindle can be online inspection or offline inspection in packaging lines, etc., and this application does not impose strict limitations.
[0069] The present invention will be further described below with reference to the accompanying drawings and embodiments, but this should not be construed as limiting the present invention.
[0070] Reference Figure 2 The method for detecting fuzzy defects on the surface of chemical fiber spindles, as provided in the first embodiment of the present invention, includes the following steps:
[0071] Step S01: Set up the detection device;
[0072] Step S02: Acquire an image of the spindle product to be inspected;
[0073] Step S03: Use the algorithm to segment the original image and obtain the mask annotation;
[0074] Step S04: Construct a pre-training dataset using the original images and mask annotations;
[0075] Step S05: Pre-train the U-Net model using the pre-training dataset to obtain the pre-trained model;
[0076] Step S06: Perform weakly supervised training on the pre-trained model to obtain a weakly supervised trained model;
[0077] Step S07: Input the sample to be detected into the weakly supervised training model for inference to obtain the hair segmentation image in the sample;
[0078] Step S08: Organize the hair segmentation image to obtain defect information in the sample;
[0079] Step S09: Output defect information.
[0080] The detection device constructed in step S01 is as follows Figure 6 As shown, it includes:
[0081] The spindle conveying module is used to deliver and remove spindles to and from the shooting station;
[0082] The spindle position determination module is used to determine when the spindle arrives at the shooting station;
[0083] The image acquisition module is used to acquire images of the wire spindle at the camera station;
[0084] The image information maintenance module is used to determine the source spindle of the acquired image;
[0085] The control module is used to integrate information and implement control.
[0086] In specific implementation, each module can be implemented according to the following scheme:
[0087] The spindle conveying module conveys the spindles via roller conveyor 100. The roller conveyor is equipped with a tray to support the spindles. The roller conveyors can be connected to each other to adapt to actual working conditions. The roller conveyors are controllable.
[0088] The spindle position determination module senses the position of the tray 301 through the sensor 200, and generates a signal when the tray 301 passes through a specific position.
[0089] The image acquisition module includes a light source 401 and related lighting environment equipment, a camera 402 and its imaging system; the related lighting environment equipment includes a darkroom and a background panel. The image acquisition module is in a fully controlled state, capable of receiving control signals and responding stably. The light source can be turned on or off via signals, and the camera can be controlled to acquire and output images via signals. The camera 402's lens faces the side of the spindle 302, and its height is adjustable, ideally positioned to face the top surface of the spindle 302 from the side.
[0090] The image information maintenance module can output the identification information of a specified spindle to determine the source of the spindle from which the image acquisition module acquires potential filament images. Specifically, the RFID sensor 500 determines the number of the tray 301, and based on the recorded correspondence between tray 301 and spindle 302, determines and outputs the identification information of the spindle on that tray. The RFID sensor 500 is controllable and can output the tray number information.
[0091] The control module uses an industrial controller to integrate the information from the above modules and implement control according to a pre-set program.
[0092] In a preferred embodiment of the present invention, step S02 is as follows: First, the above modules are connected, and the control module receives the signal from the spindle position determination module. The response to the state transition signal is set, and the response includes: first, controlling the image information maintenance module to output the product information of the spindle at the current shooting station, then turning on the light source to expose the shooting environment for a certain period of time, then controlling the camera to capture the image, and outputting the acquired image.
[0093] In a preferred embodiment of the present invention, step S03 specifically includes the following steps:
[0094] The original image is filtered using Gaussian filtering, median filtering, and mean filtering to obtain a denoised image.
[0095] The Canny algorithm was used to extract the spindle edge map and the hair edge map from the denoised image, respectively.
[0096] Based on the spindle edge map, remove the spindle edges from the fuzz edge map to obtain the fuzz map;
[0097] The hair pattern is subjected to dilation and erosion operations to obtain the hair mask image.
[0098] Figure 3A The above steps are for the edge diagram of the hair fibers, which includes the edge of the hair fibers, the edge of the spindle, and the texture edge on the spindle; Figure 3B This is a diagram of the silk spindle edge, including the silk spindle edge and a small amount of silk spindle texture edge; Figure 3C The image is a depiction of hair and silk threads. Figure 3B The edge diagram of the silk spindle shown is for reference. Figure 3A The result is obtained by removing the edges of the silk spindle and the edges of the texture on the silk spindle. A specific removal method could be: traversing by column index... Figure 3B For all columns, iterate through the pixels of that column from top to bottom. When you find the first pixel with a non-zero value, adjust its current coordinates. Figure 3B Set the pixel at that coordinate and its lower pixel to 0; completing the above process will yield the result. Figure 3C Hair-like pattern.
[0099] In a preferred embodiment of the present invention, step S04 includes the following steps:
[0100] Using the edge of the spindle as the center of the window, a sliding window is used to extract data blocks. Specifically, the sliding window method is used to extract data blocks at corresponding positions in the image and the mask image according to an adaptive trajectory. The adaptive trajectory must include all areas where there may be fuzz defects. One possible approach is to use the edge of the spindle obtained in step S03 as the moving trajectory of the sliding window. The size of the sliding window is 256×256 pixels, and the horizontal step size is 128 pixels.
[0101] Calculate the sum of gray values of the image portion in all data blocks, and remove data blocks that do not contain spindles based on the sum of gray values to obtain the pre-trained dataset.
[0102] In a preferred embodiment of the present invention, step S05 has the following technical solution steps:
[0103] To build an improved U-Net model for small datasets, the first step is to construct, as follows: Figure 4 The smallest unit for feature extraction and feature fusion is shown in the diagram. A convolution-convolution-max pooling block is constructed as the smallest unit for feature extraction; a convolution-convolution-upsampling block is constructed as the smallest unit for feature fusion. Dropout layers are used to optimize the network and ensure its generalization ability.
[0104] The loss function used is the Focal loss function, which is designed for tasks with imbalanced positive and negative samples. The formula for the Focal loss function is as follows:
[0105]
[0106] Where N represents the number of pixels, α represents the category weight, γ represents the focus weight, and p i y represents the category prediction value. i This represents the label value. The focus coefficient γ allows the model training to pay more attention to difficult samples, while the class weight α balances the impact of differences in the number of samples between classes on training.
[0107] The network was trained using a pre-trained dataset. The Adam optimizer was used for training with a fixed learning rate of 0.0001. The number of training iterations was fixed at 50.
[0108] In a preferred embodiment of the present invention, such as Figure 5 As shown, step S06, the technical solution steps for one training cycle are as follows:
[0109] Weakly supervised training is performed in a fixed number of rounds. Each round of weakly supervised training includes two steps: weak label update and network parameter update. The pre-training data label set obtained in step three is used as the initial label L for weakly supervised training.
[0110] First, weak label updates are performed. The U-Net model is used to infer the training set samples to obtain the probability map Y directly predicted by the U-Net model. The probability map Y is adjusted using DenseCRF to obtain the probability map Y′. According to the confidence threshold T, the pixels with a probability less than T in the probability map Y′ are marked as background, and the remaining pixels are marked as foreground to obtain the label map L′. The original label map L is replaced with the label map L′.
[0111] The network was then updated, and the U-Net network was trained using the labeled graph L. The Adam optimizer was selected, and the learner rate was set to 0.0001.
[0112] Weak label updates and network parameter updates are performed alternately. Each iteration of weakly supervised training begins with a weak label update and ends with a complete network parameter update. Weakly supervised training is fixed at 30 epochs, and the best-performing model among these 30 epochs is selected as the final model.
[0113] This invention employs a gradient segmentation algorithm to obtain original labels with low accuracy but high consistency. DenseCRF and a label update algorithm are used to dynamically modify the labels during training, gradually removing mislabeling caused by noise and recovering missing labels due to low grayscale values, thereby obtaining labels with stronger consistency and higher accuracy. A pre-training method is introduced: before weakly supervised training, supervised learning is used to pre-train the model with fixed labels, improving the stability of weakly supervised training.
[0114] In a preferred embodiment of the present invention, step S07 comprises the following technical steps:
[0115] Use a sliding window to crop all windows in the spindle image that may contain fuzz as samples to be detected;
[0116] The sample to be detected is input into the weakly supervised model obtained in step S06 for inference to obtain the hair prediction map;
[0117] Using a binarization algorithm, pixels in the hair prediction image are classified as foreground or background to obtain a hair segmentation image.
[0118] In a preferred embodiment of the present invention, step S08 includes the following steps:
[0119] Generate a blank mask image based on the original image dimensions;
[0120] The mask image in the segmented image is restored to the blank mask image according to the position of the sample in the original image, so as to obtain the overall segmentation map containing the segmentation information of all samples in the image.
[0121] Morphological closing operations are performed on the overall segmentation image to obtain a continuous hair mask image;
[0122] The contour detection algorithm is used to extract the contours of each hair block, the contours are labeled and the area of each contour is calculated.
[0123] Sort the hair bristle blocks according to their area size, and count the number of hair bristle blocks in different area ranges and the bounding box information of each hair bristle block.
[0124] This invention provides a method for detecting defects in fuzz on chemical fiber spindles, enabling accurate extraction of information such as the number, area, and bounding box of fuzz. Firstly, an acquisition device suitable for the above detection method is provided. This device can acquire images of the spindle from multiple angles and at multiple brightness levels. Addressing the issue of poor consistency in manually labeled images with motion blur and out-of-focus areas, a weakly supervised learning paradigm is introduced. Simple pixel-level weak labels are obtained through edge extraction and morphological operations. Errors in the weak labels are corrected during the iterative process. No manual labels are introduced throughout the process, avoiding errors caused by inaccurate manual supervision, ultimately resulting in a detection model with an accuracy of 94.55%.
[0125] Furthermore, the present invention introduces a deep learning model, which makes the detection algorithm robust to interference factors such as illumination, shooting angle, and spindle posture deviation, and can adapt to changes in the light environment caused by light source aging and spindle vibration caused by roller aging.
[0126] Furthermore, the detection algorithm of this invention can adapt to hairs of different shapes. Specifically, random sampling without replacement was performed on a test set with a total of 750 samples to obtain five mutually exclusive subsets with 150 samples each. The detection algorithm was tested on these subsets, and the performance test results are shown in Table 1. It can be seen that the accuracy of the detection algorithm remains stable on different subsets, while the hair shapes in the mutually exclusive subsets are different, indicating that the detection algorithm can adapt to hairs of different shapes. Table 1:
[0127]
[0128] Furthermore, the detection algorithm in this invention has low requirements for initial training labels, which can be generated by simple image processing algorithms. Specifically, the accuracy of the initial training labels used in this invention is 72.24%, and a detection model with an accuracy of 94.55% can be obtained in the end; it has certain advantages in terms of transferability.
[0129] The embodiments of the present invention can adapt to uncertain images and hair of different shapes, and can be extended to a wider range of applications.
[0130] Based on the description and accompanying drawings of this invention, those skilled in the art can easily manufacture or use the device and method for collecting and detecting appearance defects of a wire spindle according to this invention, and can achieve the positive effects described in this invention.
[0131] It should be noted that the terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this invention are intended to cover non-exclusive inclusion. The terms "installed," "set," "equipped with," "connected," "linked," and "sleeve" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral construction; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium, or an internal connection between two mechanisms, elements, or components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances. The terms "first" and "second" are used only for brevity in description and do not indicate or imply relative importance.
[0132] Furthermore, in practicing the claims of this invention, those skilled in the art can understand and influence variations to the disclosed embodiments through a study of the drawings, the disclosure, and the appended claims. Additionally, in the claims and description, words such as "comprising" and "containing" do not exclude other elements or steps, and non-plural nouns do not exclude their plural forms.
[0133] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of the present invention. All equivalent changes and modifications made in accordance with the present invention are covered by the scope of the claims of the present invention, and will not be listed here.
Claims
1. A weakly supervised learning based image detection method for yarn defects, characterized in that, The method comprises the following steps: Step one: obtaining an original image of a silk ingot product to be detected; Step two: segmenting the original image using an algorithm to obtain a mask annotation; Step three: constructing a pre-training data set using the original image and the mask annotation; Step four: pre-training a U-Net model using the pre-training data set to obtain a pre-trained model; Step five: performing weak supervision training on the pre-trained model obtained in step four to obtain a weak supervision training model; The weak supervision training is performed according to a fixed number of rounds, each round of weak supervision training comprises two steps: weak label updating and network parameter updating, and the weak label updating and the network parameter updating are alternately performed in the whole training process; the pre-training data label set obtained in step three is used as the initial label for the weak supervision training; firstly, the weak label updating is performed, the U-Net model is used to infer the training set samples to obtain a probability map directly predicted by the U-Net model; the probability map is adjusted using the DenseCRF to obtain a probability map; according to a confidence threshold, pixels with a probability value less than the confidence threshold in the probability map are marked as background, and the remaining pixels are marked as hair silk to obtain a marked map; the marked map is used to replace the original marked map; then, the network updating is performed, and the U-Net network is trained using the original image and the updated marked map of the sample; after the two steps are completed, the model obtained in the round is tested for performance using test set data, and the test result and the model parameters are saved; After the weak supervision training is completed, the model and the test result obtained in the weak supervision training process are used to retain the parameter group with the highest accuracy; Step six: inputting a sample to be detected into the weak supervision training model for inference to obtain a hair silk segmentation image in the sample; Step seven: arranging the hair silk segmentation image to obtain defect information in the sample; Step eight: outputting the defect information; The step two comprises the following steps: Step 2.1: filtering the original image using Gaussian filtering, median filtering and mean filtering to obtain a denoised image; Step 2.2: extracting a silk ingot edge map and a hair silk edge map from the denoised image using a Canny algorithm; Step 2.3: removing the silk ingot edge in the hair silk edge map according to the silk ingot edge map to obtain a hair silk edge map; Step 2.4: performing a morphological closing operation on the hair silk edge map to obtain a hair silk mask annotation; The step three comprises the following steps: Step 3.1: taking the silk ingot edge as the center of a window, and sliding the window to cut an image block; Step 3.2: calculating the total sum of the gray values of all the image blocks, and removing the image blocks not containing the silk ingot according to the total sum of the gray values to obtain a pre-training data set.
2. The weakly supervised learning based image detection method of the thread defects according to claim 1, characterized in that, Before step one, a detection device is built, and the detection device comprises the following modules: A silk ingot conveying module for conveying the silk ingot to and away from a shooting station; A silk ingot position determination module for capturing a silk ingot passing through the shooting station event; An image acquisition module for acquiring an image of the silk ingot at the shooting station; An image information maintenance module for determining the source silk ingot of the acquired image; A control module for integrating sensor signals and implementing control. 3.The weakly supervised learning based image detection method of the hairpin defect according to claim 2, characterized in that, The step one comprises the following process: Placing the silk ingot to be detected on a tray in a roller way of the silk ingot conveying module; the roller way conveys the silk ingot to pass through the shooting station to trigger a signal; The control module receives and responds to the trigger signal, and sequentially performs the following operations: controlling the image information maintenance module to output the number of the silk spool at the current shooting station, controlling the light source in the image acquisition module to light, and controlling the camera in the image acquisition module to capture images. The camera outputs the image. 4.The weakly supervised learning based image detection method of yarn defects according to claim 1, characterized in that, The step five includes the following steps: Step 5.1: explicitly taking the pre-training data label set obtained in step three as the initial label of weakly supervised training; Step 5.2: weakly supervised training of the pre-training model; Step 5.3: according to the model and test results obtained in the weakly supervised training process, select the optimal performance as the final detection model. 5.The weakly supervised learning based image detection method of the yarn defect according to claim 1, characterized in that, The step six includes the following steps: Step 6.1: using the image block interception method adopted in step three, intercepting image blocks from the image to be detected to obtain the detection sample; Step 6.2: input all the detection samples into the final detection model for inference to obtain a prediction map. 6.The weakly supervised learning based image detection method of the yarn defect according to claim 1, characterized in that, The step seven includes the following steps: Step 7.1: generating a blank mask image according to the size of the original picture; Step 7.2: restoring the mask image in the segmented image to the corresponding position in the blank mask image to obtain an overall segmentation map containing segmentation information of all samples on the image; Step 7.3: performing morphological closing operation on the overall segmentation map to obtain a continuous hair mask map; Step 7.4: using the findContours algorithm to extract the contour of each hair block, labeling the contour and calculating the area of each contour; Step 7.5: sorting the hair blocks according to the area size, and counting the number of hair blocks in different area intervals and the bounding box information of each hair block.
7. The weakly supervised learning based image detection method of a hairpin defect according to claim 1, characterized in that, The step 2.2: using Canny algorithm to extract the silk spool edge image and the hair edge image from the denoising image, which is specifically: Taking the silk spool edge as a reference, sampling the pixel gray scale on the upper and lower sides of the silk spool edge in the denoising image; respectively, the average pixel gray scale of the upper and lower positions is obtained, and the difference between the background average pixel gray scale and the silk average pixel gray scale is taken as an adaptive reference parameter; multiply the adaptive reference parameter by the difference coefficient to obtain two groups of adaptive threshold values of the two Canny algorithms; According to the adaptive threshold, the silk spool edge image and the hair edge image are calculated.
Citation Information
Patent Citations
Methods, apparatus, electronic equipment and storage media for detecting surface defects of chemical fiber spindles
CN113344923B
Methods, storage media and equipment for detecting and classifying defects in the appearance of wire spindles
CN114299065B
Colorectal cancer digital pathological image discrimination method and system based on weak supervised learning
CN113221978A
Chemical fiber spindle surface defect detection method and device, electronic equipment and storage medium
CN113344923A