Data-driven method and apparatus for detecting defects in hygiene products under weak supervision

By using a data-generated clipping enhancement strategy, pseudo-defect images are generated to train the model, solving the problems of insufficient samples and inaccurate labeling in the manufacturing of hygiene products. This achieves efficient defect detection with limited labeled data and improves the robustness and accuracy of the model.

CN116385790BActive Publication Date: 2026-04-03GUILIN UNIV OF ELECTRONIC TECH
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-07
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

Existing technologies suffer from insufficient samples, inaccurate labeling, and an inability to handle novel defects in defect detection. This is particularly true in the manufacturing of hygiene products, where it is difficult to obtain sufficient labeled data and the labeling quality is low, leading to inaccurate model training results.

Method used

We employ a data-driven, weakly supervised approach to generate pseudo-defect images using a clipping enhancement strategy. We then use positive and negative samples to create local irregularities and train a model to recognize these irregularities, thus simulating unseen real-world defects.

Benefits of technology

It improves the model's performance and generalization ability, enabling accurate detection of surface defects in hygiene products with limited labeled data, reducing labor costs and error rates, and adapting to different types of surface defect detection tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116385790B_ABST
    Figure CN116385790B_ABST
Patent Text Reader

Abstract

This invention relates to a data-generated, weakly supervised method and apparatus for detecting defects in hygiene products. The method includes: training a defect detection model; detecting whether a newly input test image is defective based on the trained defect detection model; if the newly input test image is detected as defective, generating a pseudo-defect image based on a clipping enhancement strategy, wherein the pseudo-defect image corresponds to the defective image; and locating defects in the pseudo-defect image based on the trained defect detection model to obtain defect location information. This invention introduces irregularity through a clipping enhancement strategy, uses only normal images for training, and requires a small number of labeled defective images. It achieves high accuracy and robustness in different types of surface defect detection tasks, while requiring minimal labeled data and manual intervention.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer vision and machine learning, and specifically relates to a method and apparatus for detecting defects in hygiene products based on data generation under weak supervision. Background Technology

[0002] In manufacturing, weakly supervised defect detection is a crucial technology. It can automatically detect defects in the manufacturing process with limited labeled data, improving production efficiency and product quality while reducing costs and the risk of human error. Currently, weakly supervised learning is becoming increasingly important in fields such as natural language processing and computer vision. It uses limited labeled data to optimize feature extractors through contrastive learning, designing different agent tasks, or using hybrid tasks, and then applies these optimizations to downstream tasks. Because weakly supervised learning requires limited labeled information during the feature representation learning stage, it has wide applications in natural scene image processing, medical image processing, remote sensing image processing, and industrial inspection.

[0003] However, in practical applications, the following defects often exist, which limit the further application of supervised learning: (1) Insufficient samples: Supervised defect detection methods require a large amount of labeled data for model training, but in reality, it is often difficult to obtain enough labeled data, especially in some special fields or industries where there are many types of defects and a wide variety of types, requiring a lot of time and manpower to label them. (2) Inaccurate labeling: The quality of labeled data has a great impact on the training effect of the model, but in reality, there are often problems with inaccurate labeling, including labeling errors and inconsistent labeling, which will lead to inaccurate training results of the model. (3) Inability to handle new defects: Supervised defect detection methods need to label all defect types during model training, so after the model is trained, it cannot handle new defects well. Summary of the Invention

[0004] This invention provides a data-generated, weakly supervised method and apparatus for detecting defects in hygiene products, aiming to at least solve one of the technical problems existing in the prior art. The proposed data-generated, weakly supervised method and apparatus for detecting defects in hygiene products employs a clipping data generation strategy to create local irregularities. This strategy is used to generate surface defect data for hygiene products, fully utilizing positive and negative samples through a clipping mechanism to create local irregularities. This generates pseudo-defect images, enriching the dataset and improving model performance, making it more suitable for real-world scenarios. The model is then trained to recognize these local irregularities, with the goal of simulating unseen real defects during testing. A local irregularity is created in the image by erasing a randomly selected small rectangular region. A patch-level estimator extracts dense features from the local patch to generate a defect score map, which is then max-pooled for detection or upsampled for localization.

[0005] The technical solution of the present invention relates to a method and apparatus for detecting defects in hygiene products based on data generation under weak supervision. The method includes the following steps:

[0006] S100. Based on the trained defect detection model, detect whether the newly input test image is a defective image;

[0007] S200. If the newly input test image is detected as a defective image, a pseudo-defective image is generated based on the clipping enhancement strategy, and the pseudo-defective image corresponds to the defective image.

[0008] S300. Based on the trained defect detection model, perform defect localization on the pseudo-defect image to obtain defect location information.

[0009] Furthermore, the training steps of the defect detection model include:

[0010] S110. Collect images of the surface of sanitary products to form a training set, and classify the images in the training set. The images of the surface of sanitary products include defective images and non-defective images. The defective images include defective images of various different defect types.

[0011] S120. For the defect-free images in the training set, generate pseudo-defect images based on the clipping enhancement strategy;

[0012] S130. Based on the defect-free image and the corresponding pseudo-defect image, a first binary classifier is constructed. The first binary classifier is used to determine whether an image is the original defect-free image.

[0013] S140. Input the defect-free image and the corresponding pseudo-defect image into the pre-trained model, and perform feature extraction and splicing in the pre-trained model to generate a spliced ​​feature vector.

[0014] S150. Based on the concatenated feature vectors, train a defect detection model, wherein the defect detection model is a second binary classifier.

[0015] Furthermore, step S140 also includes:

[0016] S141. Preprocess the input image based on ImageNet, including subtracting the mean of the input image and dividing by the standard deviation of the input image;

[0017] S142. Input the preprocessed input image into the convolutional layer and pooling layer;

[0018] S143. The input image processed by the convolutional layer and the pooling layer is input into the average pooling layer;

[0019] S144. The input image processed by the average pooling layer is input to the MLP projection head, which includes three fully connected layers connected in sequence, and each fully connected layer includes a corresponding activation function.

[0020] S145. The input image processed by the MLP projection head is input into the linear layer.

[0021] Furthermore, step S140 also includes:

[0022] S146. Construct a Gaussian density estimator for the defect detection model. The Gaussian density estimator includes an image-level estimator and a patch-level estimator. The image-level estimator makes an overall decision for defect detection, and the patch-level estimator extracts dense features from local areas to generate a defect scoring map. The logarithmic density of the Gaussian density estimator is calculated as follows:

[0023]

[0024] Where x is the input sample, f(x) represents the cut patch, μ is the sample mean, and Σ is the covariance matrix of the dimensional random variables;

[0025] S147. Perform maximum pooling detection or upsampling location on the defect scoring map.

[0026] Furthermore, the defect scoring map includes anomaly scores, which are used to evaluate anomaly detection in the test image.

[0027] For each hygiene product surface image, the feature vector of the hygiene product surface image is input into the Gaussian density estimator to obtain an anomaly score;

[0028] Each abnormal score is sorted in ascending order. Based on a preset threshold, images with abnormal scores greater than the threshold are marked as defective images, and images with abnormal scores less than or equal to the threshold are marked as defect-free images.

[0029] Furthermore, the anomaly score is also used to locate defective images, wherein,

[0030] The location of the anomaly in the test image is determined based on the magnitude of the anomaly score of the defective image.

[0031] Furthermore, the defective images include blocky defect images, dotted defect images, hole-like defect images, and wrinkled defect images.

[0032] Furthermore, the clipping enhancement strategy includes:

[0033] Cut out a square area of ​​variable shape and scale from the surface image of the sanitary product, randomly rotate or shake the cut area, and paste it back to the surface image of the sanitary product at a random position;

[0034] The features of the cut defect sample are selected, and the position and size are randomly chosen. The defect sample is then rotated and shaken to form a pseudo-defect image.

[0035] The present invention also proposes a computer-readable storage medium for a data-generated, weakly supervised method for detecting defects in hygiene products. The computer-readable storage medium includes a stored program, wherein the program, when running, controls the device where the computer-readable storage medium is located to implement the aforementioned data-generated, weakly supervised method for detecting defects in hygiene products.

[0036] This invention also proposes an apparatus for a method of detecting defects in hygiene products under weak supervision, comprising:

[0037] Image acquisition unit and computer-readable storage medium.

[0038] According to some embodiments of the present invention, the beneficial effects of the present invention are as follows:

[0039] This invention proposes a data-driven, weakly supervised defect detection method for hygiene products. It employs a two-stage framework to construct the defect detector. In the first stage, deep features are learned from normal data and generated pseudo-samples. Then, a classifier is constructed using the learned representations. Subsequently, a novel method for learning self-supervised representations through predicted clipping enhancements is proposed, and this is extended to learning and extracting representations from local patches. Defect patterns in defect detection typically include irregularities such as blocks, holes, creases, and stains. The model is trained to identify these local irregularities, with the aim of generalizing to unseen real-world defects during testing.

[0040] During training, irregularities are introduced through a clipping enhancement strategy, enabling the model to capture defect patterns and detect and locate unknown defects. This invention uses only normal images for training and requires only a small number of labeled defect images. The method of this invention can achieve high accuracy and robustness in different types of surface defect detection tasks, and requires only a small amount of labeled data and manual intervention, which can greatly reduce labor costs and error rates.

[0041] Furthermore, additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0042] Figure 1 This is a flowchart of a data-driven, weakly supervised method for detecting defects in hygiene products.

[0043] Figure 2 This is a flowchart of training a defect detection model for a data-driven, weakly supervised method for detecting defects in hygiene products.

[0044] Figure 3 This is a flowchart of the pre-trained model processing for a data-driven, weakly supervised method for detecting defects in hygiene products.

[0045] Figure 4 This is a schematic diagram illustrating the generation of image-level clipping data for a data-driven, weakly supervised method for detecting defects in hygiene products.

[0046] Figure 5 This is a schematic diagram illustrating patch-level clipping data generation for a data-driven, weakly supervised method for detecting defects in hygiene products.

[0047] Figure 6 This is a flowchart of a data-driven, weakly supervised method for detecting defects in hygiene products.

[0048] Figure 7 A t-SNE visualization of block defect images from a data-generated, weakly supervised method for detecting defects in hygiene products.

[0049] Figure 8 A t-SNE visualization of wrinkled defect images from a data-generated, weakly supervised method for detecting defects in hygiene products.

[0050] Figure 9 A t-SNE visualization of point defect images from a data-generated, weakly supervised method for detecting defects in hygiene products.

[0051] Figure 10 A t-SNE visualization of hole-like defect images from a data-generated, weakly supervised method for detecting defects in hygiene products.

[0052] Figure 11 This is an image showing the enhanced effect of a data-driven, weakly supervised method for detecting defects in hygiene products, achieved through a data generation strategy that utilizes clipping data. Detailed Implementation

[0053] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0054] The following will provide a clear and complete description of the concept, specific structure, and technical effects of the present invention in conjunction with the embodiments and accompanying drawings, so as to fully understand the purpose, solution, and effects of the present invention.

[0055] It should be noted that, unless otherwise specified, when a feature is referred to as "fixed" or "connected" to another feature, it can be directly fixed or connected to the other feature, or indirectly fixed or connected to the other feature. The singular forms "a," "described," and "the" used herein are also intended to include the plural forms, unless the context clearly indicates otherwise. Furthermore, unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in this specification is for the purpose of describing particular embodiments only and not for limiting the invention. The term "and / or" as used herein includes any combination of one or more of the associated listed items.

[0056] It should be understood that although the terms first, second, third, etc., may be used in this disclosure to describe various elements, these elements should not be limited to these terms. These terms are only used to distinguish elements of the same type from each other. For example, a first element may also be referred to as a second element without departing from the scope of this disclosure, and similarly, a second element may also be referred to as a first element. Any and all instances or exemplary language (“e.g.,” “such as,” etc.) used herein are intended only to better illustrate embodiments of the invention and, unless otherwise required, do not impose a limitation on the scope of the invention. Furthermore, the industry term “pose” as used herein refers to the position and orientation of an element relative to a spatial coordinate system.

[0057] Reference Figures 1 to 11 This invention provides a data-driven, weakly supervised method and apparatus for detecting defects in hygiene products, referring to... Figure 1 The method includes the following steps:

[0058] S100. Based on the trained defect detection model, detect whether the newly input test image is a defective image;

[0059] S200. If the newly input test image is detected as a defective image, a pseudo-defective image is generated based on the clipping enhancement strategy, and the pseudo-defective image corresponds to the defective image.

[0060] S300. Based on the trained defect detection model, perform defect localization on the pseudo-defect image to obtain defect location information.

[0061] Furthermore, refer to Figure 2 The training steps of the defect detection model include:

[0062] S110. Collect images of the surface of sanitary products to form a training set, and classify the images in the training set. The images of the surface of sanitary products include defective images and non-defective images. The defective images include defective images of various different defect types.

[0063] S120. For the defect-free images in the training set, generate pseudo-defect images based on the clipping enhancement strategy;

[0064] S130. Based on the defect-free image and the corresponding pseudo-defect image, a first binary classifier is constructed. The first binary classifier is used to determine whether an image is the original defect-free image.

[0065] S140. Input the defect-free image and the corresponding pseudo-defect image into the pre-trained model, and perform feature extraction and splicing in the pre-trained model to generate a spliced ​​feature vector.

[0066] S150. Based on the concatenated feature vectors, train a defect detection model, wherein the defect detection model is a second binary classifier.

[0067] This invention provides a method for detecting surface defects in hygiene products using weakly supervised learning, which reduces the need for labeled data and improves the robustness and versatility of the model. By using weakly supervised learning on surface defect data of hygiene products, the potential features of surface defects are learned, thereby improving the generalization ability and robustness of the model.

[0068] The clipping data generation strategy proposed in this invention uses positive and negative samples to create local irregularities, thereby generating pseudo-samples, which simulates real sample data to the greatest extent.

[0069] The method for detecting surface defects in hygiene products of the present invention adopts a weakly supervised learning approach, which reduces the need for labeled data and can better handle problems such as class imbalance and insufficient samples in surface defect data.

[0070] This invention requires only a small amount of sample data to detect defects in hygiene products, which is beneficial for detection with a small sample size.

[0071] Furthermore, refer to Figure 3 Step S140 further includes:

[0072] S141. Preprocess the input image based on ImageNet, including subtracting the mean of the input image and dividing by the standard deviation of the input image;

[0073] S142. Input the preprocessed input image into the convolutional layer and pooling layer;

[0074] S143. The input image processed by the convolutional layer and the pooling layer is input into the average pooling layer;

[0075] S144. The input image processed by the average pooling layer is input to the MLP projection head, which includes three fully connected layers connected in sequence, and each fully connected layer includes a corresponding activation function.

[0076] S145. The input image processed by the MLP projection head is input into the linear layer.

[0077] Furthermore, step S140 also includes:

[0078] S146. Construct a Gaussian density estimator for the defect detection model. The Gaussian density estimator includes an image-level estimator and a patch-level estimator. The image-level estimator makes an overall decision for defect detection, and the patch-level estimator extracts dense features from local areas to generate a defect scoring map. The logarithmic density of the Gaussian density estimator is calculated as follows:

[0079]

[0080] Where x is the input sample, f(x) represents the cut patch, μ is the sample mean, and Σ is the covariance matrix of the random variable of dimension, where μ and Σ are learned from normal training data;

[0081] S147. Perform maximum pooling detection or upsampling location on the defect scoring map.

[0082] Specifically, the entire process can be simply summarized as follows: convolutional and pooling layers extract features, average pooling layers convert the features into one-dimensional vectors, the MLP projector projects the features into a low-dimensional space, and linear layers output the predicted labels. During training, the ResNet-18 model continuously optimizes its parameters through forward and backward propagation, thereby learning a feature representation that distinguishes between normal and defective images. This invention uses the ResNet18MLP model to process an image input of size 3x640x640.

[0083] 1) The input data size is (batch_size,channels,height,width)=(1,3,640,640), where batch_size=1 and channels=3 represent the three RGB channels.

[0084] 2) Preprocessing: Standardize the input image by subtracting the mean from ImageNet and dividing by the standard deviation.

[0085] 3) Convolutional and Pooling Layers: Data is first processed through convolutional layers in ResNet for feature extraction. In the pre-trained ResNet-18 model, the output size of the first convolutional layer is (batch_size, 64, 320, 320). Next are four residual blocks, each with two convolutional layers. The output size of each block is (batch_size, 64*2^i, H / 2^i, W / 2^i), where i represents the block number, and H and W are the height and width of the input image. In the pre-trained ResNet-18 model, the output size of the last block is (batch_size, 512, 20, 20).

[0086] 4) Next, the data passes through an average pooling layer, changing the output size from (batch_size, 512, 20, 20) to (batch_size, 512, 1, 1). This is because in the MLP projection head, we need to convert the features into one-dimensional vectors for processing by the fully connected layer.

[0087] 5) MLP Projector Head: After the average pooling layer, the data is fed into an MLP projector head. This MLP projector head contains three fully connected layers, each with a ReLU activation function. The first fully connected layer has an input size of (batch_size, 512) and an output size of (batch_size, 256). The second fully connected layer has an input size of (batch_size, 256) and an output size of (batch_size, 128). The third fully connected layer has an input size of (batch_size, 128) and an output size of (batch_size, 64).

[0088] 6) Linear Layer: Finally, the output of the MLP projector is fed into a linear layer. The input size of the linear layer is (batch_size, 64), and the output size is (batch_size, num_classes), where num_classes is the number of classes in the classification problem. The output of the linear layer represents the model's prediction of the class to which the input image belongs. The feature representation is classified by a classifier, the structure of which depends on the specific task. In a specific embodiment, a classifier with two output nodes is used for classifying normal images and defective images, respectively.

[0089] The model is trained using the cross-entropy loss function and optimized using stochastic gradient descent. The parameters are then backpropagated based on the gradient of the loss function, and updated accordingly. This process is repeated iteratively until the model converges.

[0090] Furthermore, the defect scoring map includes anomaly scores, which are used to evaluate anomaly detection in the test image.

[0091] For each hygiene product surface image, the feature vector of the hygiene product surface image is input into the Gaussian density estimator to obtain an anomaly score;

[0092] Each abnormal score is sorted in ascending order. Based on a preset threshold, images with abnormal scores greater than the threshold are marked as defective images, and images with abnormal scores less than or equal to the threshold are marked as defect-free images.

[0093] Specifically, the pre-trained ResNet-18 model is topped with an MLP projection head at the top of an average pooling layer, followed by a final linear layer. Based on the top pooling features, a Gaussian density estimator (GDE) for the defect detector is constructed. The image-level estimator makes an overall decision for defect detection. The patch-level estimator extracts dense features from local patches to generate defect scores, and then performs max pooling detection or upsampling localization on the defect score map. Anomaly scores are used for anomaly detection and localization on test images. During the testing phase, the GDE is used to model normal images, and the feature vector of the test image is passed to the GDE to calculate its anomaly score.

[0094] Specifically, the anomaly score reflects the similarity between the test image and normal images. If the anomaly score of the test image is higher than a predefined threshold, which is inferred from a subset of normal samples, then for each normal sample, its feature vector is input into a Gaussian density estimator (GDE) to obtain an anomaly score. These anomaly scores are then sorted in ascending order, and the top K percent of scores are selected as the threshold, where K is a predefined parameter. This threshold is used to compare the anomaly score with the threshold during testing to determine whether the test sample is an anomaly, and thus it can be labeled as an anomalous image. Simultaneously, the anomaly score can be used to determine the location of anomalies in the test image, as areas with higher anomaly scores are typically where anomalies are located. Therefore, the anomaly score can be used in anomaly detection and localization tasks.

[0095] By generating data from the original and enhanced images and simultaneously training a pre-trained ResNet-18 model, defect detection and localization tasks can be performed at both the image and local patch levels.

[0096] Image-level estimators represent the process of making an overall decision for defect detection. This involves aggregating local defect detection scores into a single defect score for the entire image to determine whether the image is defective. Specifically, image-level defect scores are generated by methods such as averaging or maximizing the defect scores of all local patches. Finally, the image-level defect score is compared to a predefined threshold to determine whether the image is defective.

[0097] At the patch-level estimator, the model extracts features from local image regions and generates a defect score map for locating defect areas in the image. The patch-level estimator extracts dense features from local patches and generates the defect score map using a Gaussian density estimator (GDE). Specifically, for each local patch, a corresponding feature vector is obtained from the pre-trained ResNet-18 model, and this vector is then input into the GDE to generate a defect score for that local patch. After obtaining the defect scores for all local patches, they are combined into a single defect score map for defect detection and localization.

[0098] For defect localization in the defect score map, max pooling detection and upsampling can be used. Max pooling detection performs a max pooling operation on the defect score map to find the location with the highest defect score; this location is the defect's location. Upsampling, on the other hand, upsamples the defect score map to the same size as the input image and then uses a thresholding strategy to classify defect pixels as foreground (defect) or background (normal). Finally, a connectivity component analysis algorithm is used to cluster the foreground pixels to generate bounding boxes or masks for the defect regions.

[0099] The training objective for weakly supervised representation learning in this invention is defined as follows:

[0100] L cp =E x∈χ {CE(g(x),0)+CE(g(CP(x)),1)} (1)

[0101] Where x represents the input image, X is a normal data sample from the dataset, CP(·) is the data generation strategy proposed in this invention, g is a binary classifier built based on the ResNet-18 model, and CE(·,·) represents the cross-entropy loss function for binary classification, where 0 represents normal and 1 represents that the sample is defective.

[0102] In practice, data generation, such as translation or color dithering, is applied before inputting x into g or CP.

[0103] Furthermore, the anomaly score is also used to locate defective images, wherein,

[0104] The location of the anomaly in the test image is determined based on the magnitude of the anomaly score of the defective image.

[0105] Furthermore, the defective images include blocky defect images, dotted defect images, hole-like defect images, and wrinkled defect images.

[0106] Furthermore, the clipping enhancement strategy includes:

[0107] Cut out a square area of ​​variable shape and scale from the surface image of the sanitary product, randomly rotate or shake the cut area, and paste it back to the surface image of the sanitary product at a random position;

[0108] The features of the cut defect sample are selected, and the position and size are randomly chosen. The defect sample is then rotated and shaken to form a pseudo-defect image.

[0109] Reference Figure 4 and Figure 5In this context, CNN uses the ResNet-18 network model. The Gaussian Density Estimator (GDE) is a method for estimating the probability model of data distribution. This method describes the distribution characteristics of data by estimating the mean and variance of the Gaussian distribution. In machine learning and statistics, the Gaussian Density Estimator is often used for data modeling and analysis. The anomaly score is the anomaly score obtained through GDE, which is used to determine defect samples and defect locations.

[0110] Specifically, refer to Figure 6 The clipping enhancement strategy, attached Figure 6 The attached image is a result of rotating the original image 90 degrees counterclockwise. (Refer to the original image.) Figure 6 The left image illustrates one approach: selecting a specific proportion at a random location. This method is simple and fast. It involves cropping a square region of variable shape and proportion from a regular training image, randomly rotating or jittering the cropped region, and then pasting it back into the original image at a random location. (See reference...) Figure 6 The image on the right shows another type of defect. It utilizes the defective part and randomly selects the position and size to make the defective area closer to the actual sample. The features of the defective sample are cut out, and the pixels are rotated and jittered to form a new defect pattern.

[0111] The similarity between the defects of the new strategy and real defects is credible and can be understood through defect exposure. In addition to generating from actual images, the enhancement process of this invention creates a local structure that combines defects and the sample itself, resulting in more realistic feature comparability, which is more challenging for models detecting such irregularities. While these synthetic defect samples do indeed look similar to normal defects, it remains to be seen whether they represent a good imitation of real defects.

[0112] Specifically, refer to Figures 7 to 10 Circular dots (or anomaly dots) represent pseudo-defect images, while square dots (or normal dots) represent real defective images. The t-SNE plots from the trained model show four defect types, including blocky defect images, wrinkled defect images, dotted defect images, and hole-like defect images. It is clear that a small portion of the pseudo-defect images overlap with real defective images, but they are still able to distinguish between defect-free and defective images.

[0113] Various methods exist for calculating defect scores using single-class classifiers. This invention constructs a generative classifier, such as a kernel density estimator or a Gaussian density estimator. While the non-parametric KDE is unaffected by distribution assumptions in its representation, it requires many examples for accurate calculation and is computationally expensive. For defect detection using a limited number of normal training examples, this invention considers using a simple Gaussian density estimator, GDE, whose logarithmic density is calculated as follows:

[0114]

[0115] Where x is the input sample, f(x) represents the cut patch, μ is the sample mean, Σ is the covariance matrix of the dimensional random variable, and μ and Σ are learned from normal training data;

[0116] While this invention proposes a method for learning a holistic image representation, learning representations of local image patches is preferred if the goal is to locate defective regions beyond image-level detection. This can be achieved through two cropping data generation strategies. By learning and extracting representations of local image patches, this invention establishes a defect detector that can calculate scores for image patches and then use them to locate defective regions. During training, a patch needs to be cropped before applying the cropping data generation strategy. Similar to Equation (1), the training objective can be expressed as achieving more expressive density modeling when learning local patch representations, where Gaussian mixtures represent an intermediate zone between KDE and Gaussian density estimators (GDEs). Although no significant performance improvements have been observed empirically, this approach can improve localization accuracy and efficiency. The training objective can be expressed as:

[0117] E x∈χ {CE(g(c(x)),0)+CE(g(CP(c(x))),1)} (3)

[0118] Where x represents the input image, c(x) represents cropping a local patch and the defective portion at a random position at x. x represents the input image, X is a normal data sample from the dataset, CP(·) is the cropping data generation strategy proposed in this invention, g is a binary classifier built based on the ResNet-18 model, and CE(·,·) represents the cross-entropy loss function for binary classification, where 0 represents normal and 1 represents that the sample is defective. During testing, embeddings are extracted from all local patches with a given stride. For each local patch, its defect score is evaluated, and the score is propagated to each pixel using Gaussian smoothing. c(x) represents cropping a local patch at a random position at x. During testing, this invention extracts embeddings from all patches with a given width. For each local patch, this invention evaluates its defect score and propagates the score to each pixel using Gaussian smoothing.

[0119] The present invention also proposes a computer-readable storage medium comprising a stored program, wherein, when the program is executed, it controls the device containing the computer-readable storage medium to implement the above-described data-generated weakly supervised method for detecting defects in hygiene products.

[0120] This invention also proposes an apparatus for a data-generated, weakly supervised method for detecting defects in hygiene products, comprising:

[0121] An image acquisition unit and a computer-readable storage medium are provided. The image acquisition unit is used to acquire images of the surface of sanitary products, and the device is used to implement the above-described data-generated weakly supervised sanitary product defect detection method.

[0122] The data-generated, weakly supervised method for detecting defects in hygiene products proposed in this invention and its beneficial effects are as follows:

[0123] A two-stage framework is employed to construct the defect detector. In the first stage, deep representations are learned from normal data, and then a classifier is built using the learned representations. A novel method for learning self-supervised representations by predicting clipping enhancements is then proposed, and this is extended to learning and extracting representations from local patches. Defect patterns in defect detection typically include irregularities such as blocks, holes, creases, and blemishes. The model is trained to identify these local irregularities, with the aim of generalizing to unseen real-world defects during testing.

[0124] During training, irregularities are introduced through a clipping enhancement strategy, enabling the model to capture defect patterns and detect and locate unknown defects. This invention uses only normal images for training and requires only a small number of labeled defect images. The method of this invention can achieve high accuracy and robustness in different types of surface defect detection tasks, and requires only a small amount of labeled data and manual intervention, which can greatly reduce labor costs and error rates.

[0125] The sanitary product defect dataset used in this invention was collected directly on the factory production line and obtained through a series of methods such as cleaning, sorting, and labeling. It lacks accurate definition, the differences between different types are not significant, the location and shape of defects of the same type are not fixed, and the distribution of samples is uneven.

[0126] Surface defect detection in hygiene products refers to the inspection and classification of non-conforming samples. However, it differs from general classification and inspection tasks due to challenges such as limited sample size and small defect sizes. In hygiene product datasets, the number of defective samples is unevenly distributed, exhibiting diverse scales and forms, with some defects representing a very small percentage while others represent a large percentage. This raises the issue that obtaining satisfactory detection results is difficult when the number of collected defective samples is limited and the defect morphology is complex. Various methods exist to address this problem, such as data generation, oversampling, loss function design, and training strategies. Data augmentation can reasonably expand the dataset and is widely used for network optimization, especially in hygiene product industry datasets—where defect data samples are few and the data types are extremely imbalanced. Therefore, proposing data generation methods under these conditions requires not only expanding the dataset but also reducing the imbalance ratio of samples to ensure the model's robustness in real-world applications.

[0127] To address the limited number of defect samples in this invention, a clipping data generation strategy is proposed to generate pseudo-defect examples using the original features of the defect data, thereby highly simulating the realism of the defect data. This strategy is based on the simple mechanism of clipping, collecting existing information through cropping and then pasting it to form new samples. It fully utilizes positive and negative samples to create local irregular patterns, and then trains the model to recognize these local irregularities. This aims to expand the dataset to a certain extent, extending the model's detection range to include both existing and uncollected real defects during testing. Without affecting the precision and accuracy of the sample images, this method randomly selects defect regions in the sample images, preserving the original defect data features to the maximum extent.

[0128] Reference Figure 11The experiments of this invention were conducted on a hygiene products dataset containing four defect types: blocky, dotted, punctate, and wrinkled. The dataset consists of original images and pseudo-defect images used for training, and images with various defects used for testing. The dataset has a relatively small number of images, including 246 blocky images, 43 dotted images, 5 punctate images, and 96 wrinkled images from the original dataset.

[0129] This dataset consists of normal images used for training and normal and defective images with various defects used for testing. The number of images in the dataset is relatively small, with the number of training images ranging from 60 to 391. This invention trains a single-class classifier for each defect category based on its respective samples. The invention learns representations through de novo augmentation predictions.

[0130] The key to the success of this invention lies in utilizing a patch-based data generation strategy for self-supervised learning of representations. This is a simple yet effective enhancement method that encourages the model to seek local irregularities. This invention demonstrates superior image-level defect protection performance on real-world datasets. Furthermore, by learning and extracting patch-level representations, it addresses the challenges of defect detection methods with limited sample sizes. Through weakly supervised learning, it reduces the need for labeled data, improving the model's robustness and versatility, and better handling issues such as class imbalance and insufficient samples in surface defect data. Simultaneously, this invention employs effective feature extraction and classifier design methods, enabling rapid and accurate detection and classification of various types of surface defects, improving detection accuracy and efficiency. Therefore, this invention possesses significant innovation and practicality, effectively addressing the shortcomings and problems of existing technologies.

[0131] It should be understood that the method steps in the embodiments of the present invention can be implemented or carried out by computer hardware, a combination of hardware and software, or by computer instructions stored in a non-transitory computer-readable storage medium. The method can use standard programming techniques. Each program can be implemented in a high-level procedural or object-oriented programming language to communicate with the computer system. However, if necessary, the program can be implemented in assembly or machine language. In any case, the language can be a compiled or interpreted language. Furthermore, for this purpose, the program can run on a programmed application-specific integrated circuit (ASIC).

[0132] Furthermore, the procedures described herein may be performed in any suitable order unless otherwise indicated herein or otherwise clearly contradicted by the context. The procedures described herein (or variations and / or combinations thereof) may be executed under the control of one or more computer systems configured with executable instructions, and may be implemented by hardware or a combination thereof as code (e.g., executable instructions, one or more computer programs, or one or more applications) that commonly executes on one or more processors. The computer program comprises a plurality of instructions executable by one or more processors.

[0133] Furthermore, the method can be implemented in any suitable type of computing platform, including but not limited to personal computers, minicomputers, mainframes, workstations, networked or distributed computing environments, standalone or integrated computer platforms, or in communication with charged particle tools or other imaging devices, etc. Aspects of the invention can be implemented as machine-readable code stored on a non-transitory storage medium or device, whether removable or integrated into a computing platform, such as a hard disk, optical read and / or write storage medium, RAM, ROM, etc., such that it is readable by a programmable computer, and when the storage medium or device is read by the computer, it can be used to configure and operate the computer to perform the processes described herein. Furthermore, the machine-readable code, or portions thereof, can be transmitted via wired or wireless networks. The invention described herein includes these and other different types of non-transitory computer-readable storage media when such media comprises instructions or programs that implement the steps described above in conjunction with a microprocessor or other data processor. When programmed according to the methods and techniques described in the invention, the invention may also include the computer itself.

[0134] A computer program can be applied to input data to perform the functions described herein, thereby transforming the input data to generate output data stored in non-volatile memory. The output information can also be applied to one or more output devices, such as a display. In a preferred embodiment of the invention, the transformed data represents physical and tangible objects, including specific visual depictions of physical and tangible objects generated on the display.

[0135] The above description is merely a preferred embodiment of the present invention. The present invention is not limited to the above-described embodiments. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention, as long as they achieve the technical effects of the present invention by the same means, should be included within the scope of protection of the present invention. Within the scope of protection of the present invention, the technical solutions and / or implementation methods can have various modifications and variations.

Claims

1. A method for detecting defects in hygiene products based on data generation under weak supervision, characterized in that, The method includes the following steps: S100. Based on the trained defect detection model, detect whether a newly input test image is a defective image; the training steps of the defect detection model include: S110. Collect images of the surface of sanitary products to form a training set, and classify the images in the training set. The images of the surface of sanitary products include defective images and non-defective images. The defective images include defective images of various different defect types. S120. For the defect-free images in the training set, generate pseudo-defect images based on the clipping enhancement strategy; S130. Based on the defect-free image and the corresponding pseudo-defect image, a first binary classifier is constructed. The binary classifier is used to determine whether an image is the original defect-free image. S140. Input the defect-free image and the corresponding pseudo-defect image into the pre-trained model, and perform feature extraction and splicing in the pre-trained model to generate a spliced ​​feature vector. S150. Based on the concatenated feature vectors, train a defect detection model, wherein the defect detection model is a second binary classifier. S200. If the newly input test image is detected as a defective image, a pseudo-defective image is generated based on the clipping enhancement strategy, and the pseudo-defective image corresponds to the defective image. S300. Based on the trained defect detection model, perform defect localization on the pseudo-defect image to obtain defect location information.

2. The method for detecting defects in hygiene products based on data generation according to claim 1, characterized in that, Step S140 further includes: S141. Preprocess the input image based on ImageNet, including subtracting the mean of the input image and dividing by the standard deviation of the input image; S142. Input the preprocessed input image into the convolutional layer and pooling layer; S143. The input image processed by the convolutional layer and the pooling layer is input into the average pooling layer; S144. The input image processed by the average pooling layer is input to the MLP projection head, which includes three fully connected layers connected in sequence, and each fully connected layer includes a corresponding activation function. S145. The input image processed by the MLP projection head is input into the linear layer.

3. The method for detecting defects in hygiene products based on data generation according to claim 1, characterized in that, Step S140 further includes: S146. Construct a Gaussian density estimator for the defect detection model. The Gaussian density estimator includes an image-level estimator and a patch-level estimator. The image-level estimator makes an overall decision for defect detection, and the patch-level estimator extracts dense features from local areas to generate a defect scoring map. The logarithmic density of the Gaussian density estimator is calculated as follows: , Where x is the input sample, f(x) represents the cut patch, μ is the sample mean, and Σ is the covariance matrix of the dimensional random variables; S147. Perform maximum pooling detection or upsampling location on the defect scoring map.

4. The method for detecting defects in hygiene products based on data generation according to claim 3, characterized in that, The defect scoring map includes anomaly scores, which are used to evaluate anomaly detection in the test image. For each hygiene product surface image, the feature vector of the hygiene product surface image is input into the Gaussian density estimator to obtain an anomaly score; Each abnormal score is sorted in ascending order. Based on a preset threshold, images with abnormal scores greater than the threshold are marked as defective images, and images with abnormal scores less than the threshold are marked as defect-free images.

5. The method for detecting defects in hygiene products based on data generation according to claim 4, characterized in that, The anomaly score is also used to locate defective images, wherein... The location of the anomaly in the test image is determined based on the magnitude of the anomaly score of the defective image.

6. The method for detecting defects in hygiene products based on data generation according to claim 1, characterized in that, The defective images include blocky defect images, dotted defect images, hole-like defect images, and wrinkled defect images.

7. The method for detecting defects in hygiene products based on data generation according to claim 1, characterized in that, The clipping enhancement strategy includes: Cut out a square area of ​​variable shape and scale from the surface image of the sanitary product, randomly rotate or shake the cut area, and paste it back to the surface image of the sanitary product at a random position; The features of the cut defect sample are selected, and the position and size are randomly chosen. The defect sample is then rotated and shaken to form a pseudo-defect image.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the method according to any one of claims 1 to 7.

9. A device for detecting defects in hygiene products under weak supervision, characterized in that, include: Image acquisition unit; The computer-readable storage medium according to claim 8.

Citation Information

Patent Citations

  • Power equipment defect detection method based on pseudo defect space generation

    CN115359054A