CN115082435A - Defect detection method based on self-supervision momentum contrast - Google Patents

Defect detection method based on self-supervision momentum contrast Download PDF

Info

Publication number
CN115082435A
CN115082435A CN202210858635.XA CN202210858635A CN115082435A CN 115082435 A CN115082435 A CN 115082435A CN 202210858635 A CN202210858635 A CN 202210858635A CN 115082435 A CN115082435 A CN 115082435A
Authority
CN
China
Prior art keywords
defect
sample
image
positive
momentum
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210858635.XA
Other languages
Chinese (zh)
Other versions
CN115082435B (en
Inventor
张晓武
陈斌
魏秀参
许玉燕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Linyan Precision Technology Co ltd
Original Assignee
Zhejiang Linyan Precision Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Linyan Precision Technology Co ltd filed Critical Zhejiang Linyan Precision Technology Co ltd
Priority to CN202210858635.XA priority Critical patent/CN115082435B/en
Publication of CN115082435A publication Critical patent/CN115082435A/en
Application granted granted Critical
Publication of CN115082435B publication Critical patent/CN115082435B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/26Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/28Quantising the image, e.g. histogram thresholding for discrimination between background and foreground patterns
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/764Arrangements for image or video recognition or understanding using pattern recognition or machine learning using classification, e.g. of video objects
    • G06V10/765Arrangements for image or video recognition or understanding using pattern recognition or machine learning using classification, e.g. of video objects using rules for classification or partitioning the feature space
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/77Processing image or video features in feature spaces; using data integration or data reduction, e.g. principal component analysis [PCA] or independent component analysis [ICA] or self-organising maps [SOM]; Blind source separation
    • G06V10/772Determining representative reference patterns, e.g. averaging or distorting patterns; Generating dictionaries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/77Processing image or video features in feature spaces; using data integration or data reduction, e.g. principal component analysis [PCA] or independent component analysis [ICA] or self-organising maps [SOM]; Blind source separation
    • G06V10/774Generating sets of training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/82Arrangements for image or video recognition or understanding using pattern recognition or machine learning using neural networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20084Artificial neural networks [ANN]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Multimedia (AREA)
  • Evolutionary Computation (AREA)
  • Computing Systems (AREA)
  • Artificial Intelligence (AREA)
  • Databases & Information Systems (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Software Systems (AREA)
  • Quality & Reliability (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

The invention relates to the technical field of single-classification image detection, and discloses a defect detection method based on self-supervision momentum comparison, which comprises the following steps: generating an original pseudo-defect image; cutting a small rectangular area with variable size and aspect ratio from the original pseudo-defect image, randomly rotating the small rectangular area and dithering pixel values, and then pasting the small rectangular area to the random position of the positive sample to form a pseudo-defect image; positive and negative sample characteristics which can obviously reflect the existence of defects are generated by utilizing a comparison learning loss function driving model, so that a normal sample and a defect sample are separated, a characteristic dictionary is maintained by utilizing a momentum comparison method, and the characteristics of the positive and negative samples are learned while the characteristics keep consistency; and calculating the defect abnormal score by using a Gaussian density estimator, and judging whether the whole image is a defect image. The method can simulate the irregularity, the continuity and the diversity of the defect data as accurately as possible, and improve the detection accuracy of the model according to the method.

Description

Defect detection method based on self-supervision momentum contrast
Technical Field
The invention relates to the technical field of single-classification image detection, in particular to a defect detection method based on self-supervision momentum comparison.
Background
Anomaly detection is intended to detect instances of anomalies and defect patterns that differ from what is seen for normal instances. Many of the problems from different vision applications are anomaly detection, including manufacturing defect detection, medical image analysis, and video surveillance. Unlike typical supervised classification problems, anomaly detection faces unique challenges.
First, due to the different nature of the problem, it is difficult to obtain large amounts of anomalous data, whether tagged or untagged. Second, the defect region may be a small and subtle high resolution image, so the difference between normal and abnormal patterns tends to be fine grained. Second, due to limited access to the anomaly data, the construction of an anomaly detector is typically done under semi-supervised or single classification settings using only normal data. Finally, since the distribution of abnormal patterns is unknown in advance, general training models only learn the existence of normal examples, and therefore these training models do not determine well whether a test sample is abnormal.
In summary, the invention provides a defect detection method based on self-supervision momentum comparison, which can construct defect data, simulate the irregularity, the continuity and the diversity of the defect data as accurately as possible, and improve the detection accuracy of a model according to the method so as to solve the problem of low accuracy of abnormal detection.
Disclosure of Invention
The invention aims to provide a defect detection method based on self-supervision momentum comparison.
The invention is realized by the following technical scheme: a defect detection method based on self-supervision momentum contrast comprises the following steps:
step S1, constructing a Gaussian noise sample image as an original pseudo-defect image according to the original positive type sample, the randomly generated mean value and the variance in the data set;
step S2, generating a negative type sample by using a sample mixing operation;
step S3, positive and negative sample characteristics which can obviously reflect the existence of defects are generated by using a contrast learning loss function driving model, so that a normal sample and a defect sample are separated, a characteristic dictionary is maintained by using a momentum contrast method, and the characteristics of the positive and negative samples are learned while the characteristics keep consistency;
and step S4, calculating the abnormal score of the defect by using a Gaussian density estimator, judging whether the whole image is a defect image, dividing the image into image blocks according to a fixed step length when the image is tested for positioning the defect, extracting features from all the image blocks, calculating the abnormal score of each image block, and transmitting the abnormal score to each pixel by using a Gaussian smoothing method.
The invention discloses a defect detection method based on self-supervision momentum comparison, which combines an original positive sample in a data set, utilizes a randomly generated mean value and variance to jointly construct a Gaussian noise sample image, utilizes a Berlin noise generator to generate a noise image, carries out binarization through a uniformly randomly sampled threshold value to form a defect distribution map, and utilizes the positive sample and the Gaussian noise sample to combine to generate an original pseudo-defect image according to the defect distribution map; cutting a small rectangular area with variable size and aspect ratio from the original pseudo-defect image, randomly rotating and dithering the pixel value of the small rectangular area, and then pasting the small rectangular area to the random position of the positive type sample to form a pseudo-defect image, namely a negative type sample; positive and negative sample characteristics which can obviously reflect the existence of defects are generated by using a comparison learning loss function driving model, so that a normal sample and a defect sample are separated as far as possible, a larger characteristic dictionary is maintained by using a momentum comparison method, and the characteristics of the positive and negative samples are learned while the characteristics are kept consistent; calculating the abnormal score of the defect by using a Gaussian density estimator, judging whether the whole image is the defect image, dividing the image into image blocks according to a fixed step length when the image positioning defect is tested, extracting features from all the image blocks, calculating the abnormal score of each image block, and transmitting the abnormal score to each pixel by using a Gaussian smoothing method. The invention provides a novel pseudo defect construction method and a training frame based on positive and negative samples, which can effectively detect defects on the aspect of single classification. The pseudo-defect sample construction method accurately simulates the irregularity, the coherence and the diversity of the defect sample, and ensures the further improvement of the learning performance of the neural network model.
In order to better implement the present invention, further, the step S1 includes:
step S11, combining the original positive samples in the data set, and constructing a Gaussian noise sample image by using the randomly generated mean value and variance;
step S12, generating a noise image by using a Berlin noise generator;
step S13, performing binarization processing on the noise image through a threshold value of uniform random sampling to form a defect distribution map;
and step S14, generating an original pseudo-defect image by combining the normal sample and the Gaussian noise sample according to the defect distribution map.
In order to better implement the present invention, further, the step S2 includes:
randomly selecting a cutting area from an original pseudo-defect image, cutting a small rectangular area with variable size and aspect ratio, randomly rotating the small rectangular area and dithering pixel values, and then pasting the small rectangular area to a random position of a positive sample to form a pseudo-defect image as a negative sample.
In order to better implement the present invention, further, the step S1 includes:
step S11, combining the original positive samples in the data set, and constructing a Gaussian noise sample image by using the randomly generated mean value and variance;
step S12, generating a noise image using a berlin noise generator;
step S13, performing binarization processing on the noise image through a threshold value of uniform random sampling to form a defect distribution map;
and step S14, generating an original pseudo-defect image by combining the normal sample and the Gaussian noise sample according to the defect distribution map.
In order to better implement the present invention, further, the step S2 includes:
a negative class sample is generated using a sample mixing operation.
In order to better implement the present invention, further, the step S3 includes:
constructing a corresponding negative sample for each positive sample through sample mixing operation, and generating a negative sample set;
combining the positive and negative sample sets to create a sample space;
generating a query view and a dictionary view by a random data expansion method, and sending the query view and the dictionary view into a corresponding query network and a corresponding dictionary network to obtain a pair of embedded vectors q and k;
and adding a classifier driving model after the network is queried for training, performing momentum updating by using the dictionary network and the query network, and performing comparison learning according to the embedded vector acquired by the dictionary network and the embedded vector acquired by the query network.
In order to better implement the present invention, further, the step S4 includes:
when the image positioning defect is tested, dividing the image into image blocks according to a fixed step length, extracting features from all the image blocks, calculating the abnormal score of each image block, and transmitting the calculated abnormal score to each pixel by using a Gaussian smoothing method;
randomly selecting an embedded vector of a sample in a training set to participate in the calculation of a total probability formula;
calculating the mean value and the variance of each embedded vector, and obtaining a total probability formula according to the obtained mean value and variance;
and for the test sample, calculating a defect abnormity score according to a total probability formula, and judging whether the whole image is a defect image according to the defect abnormity score to finish defect detection.
Compared with the prior art, the invention has the following advantages and beneficial effects:
(1) the invention provides a construction method of defect data, which can simulate the irregularity, the continuity and the diversity of the defect data as accurately as possible and improve the detection accuracy of a model according to the method;
(2) the invention utilizes the comparison learning framework to drive the model to generate positive and negative sample characteristics which can obviously reflect the existence of defects, so that the positive and negative samples are separated as far as possible;
(3) the invention maintains a larger feature dictionary by using a momentum comparison method, and learns the characterization of positive and negative samples while keeping the consistency of the features.
Drawings
The invention is further described in connection with the following figures and examples, all of which are intended to be open ended and within the scope of the invention.
Fig. 1 is a schematic diagram of defect data generation in a defect detection method based on an auto-supervision momentum contrast according to the present invention.
Fig. 2 is a schematic flow chart of a defect detection method based on auto-supervision momentum contrast according to the present invention.
Detailed Description
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it should be understood that the described embodiments are only a part of the embodiments of the present invention, and not all embodiments, and therefore should not be considered as a limitation to the scope of protection. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
In the embodiment of the invention, the mixnoise operation is a sample mixing operation, the Perlin noise generator is a Berlin noise generator, the query view is a query view, the key view is a dictionary view, the key network is a dictionary network, and the query network is a query network.
Example 1:
the defect detection method based on the auto-supervised momentum comparison of the present embodiment is a schematic diagram of defect data generation as shown in fig. 1, and two examples are illustrated to show how defect data is generated. In order to simulate the irregularity, the continuity and the diversity of the defect data as accurately as possible, a Berlin noise generator is used for generating a noise image with the same size as a sample, and a defect distribution diagram is formed by binarizing the noise image through a uniform random sampling threshold value
Figure 609280DEST_PATH_IMAGE001
And randomly generating a mean value and a variance for each positive sample in the data set, generating Gaussian noise according to the values of the mean value and the variance and the size of the positive sample, and superposing the Gaussian noise on the positive sample to construct a Gaussian noise sample image A. The Gaussian noise sample image is distributed according to the defect distribution map
Figure 729683DEST_PATH_IMAGE001
Performing texture display and matching with the positive type sample
Figure 181524DEST_PATH_IMAGE002
Mixing to form defect anomalies beyond the distribution to obtain an original pseudo-defect image
Figure 655361DEST_PATH_IMAGE003
. From the original pseudo-defect image
Figure 282783DEST_PATH_IMAGE004
In cutting a blockAnd randomly rotating and dithering the small rectangular area, and then pasting the small rectangular area to the random position of the positive type sample to form a pseudo-defect image, namely the negative type sample. As shown in fig. 2, in the present invention, first, only normal samples without defects in the single classification defect detection data set, i.e., the original positive type samples in the data set, are constructed, and then the defect samples (negative type samples) are constructed, so that the positive type samples in the data set are used at first. Combining an original positive sample in a data set, using a numerical value generated by a random function as a mean value and a variance, using a random function random to randomly generate a numerical value as a mean value and a variance, constructing a Gaussian noise sample image with the same size as an original image according to the randomly generated mean value and variance, generating a noise image by using a Berlin noise generator, performing binarization by using a uniformly randomly sampled threshold value to form a defect distribution map, and combining the positive sample and the Gaussian noise sample to generate an original pseudo-defect image according to the defect distribution map. Secondly, cutting a small rectangular area with variable size and aspect ratio from the original pseudo-defect image, randomly rotating and dithering the pixel value of the small rectangular area, randomly rotating the rectangular area for simulating the irregularity of the defect sample by the cut small rectangular area, and then pasting the small rectangular area to the random position of the positive sample to form the pseudo-defect image, namely the negative sample. Secondly, positive and negative sample characteristics which can obviously reflect the existence of defects are generated by using a comparison learning loss function driving model, so that a normal sample and a defect sample are separated as much as possible, a larger characteristic dictionary is maintained by using a momentum comparison method, and the characteristics of the positive and negative samples are learned while the characteristics keep consistency. Finally, a Gaussian density estimator is used for calculating defect abnormal scores, the abnormal scores have two uses, and the first method is that the embedded vector of the whole image calculates the abnormal scores to judge whether the image has defects; the other method is that the abnormal score is utilized to help the image to be positioned, whether the whole image is a defect image is judged, when the image positioning defect is tested, the image is divided into image blocks according to a fixed step length, the characteristics are extracted from all the image blocks, and the abnormal score is counted for each image blockAn anomaly score is computed and propagated to each pixel using gaussian smoothing.
Example 2:
this embodiment is further optimized based on embodiment 1, in which a Perlin noise generator (berlin noise generator) is used to generate a noise image and capture various abnormal shapes, binarization is performed by a uniform random sampling threshold value to form a defect distribution map, and an original pseudo-defect image is generated by combining a normal sample and a gaussian noise sample according to the defect distribution map.
The invention is provided with
Figure 167562DEST_PATH_IMAGE005
In order to be a sample space, the sample space,
Figure 247645DEST_PATH_IMAGE006
where n is the number of samples in the dataset.
Generating a Perlin noise image (Berlin noise image) P by a Perlin noise generator (Berlin noise generator), and binarizing the noise image P by uniformly randomly sampling a threshold to form a defect distribution map
Figure 508862DEST_PATH_IMAGE007
Randomly generating a mean value and a variance value for each positive type sample in the data set, generating Gaussian noise according to the values of the mean value and the variance value and the size of the positive type sample, and superposing the Gaussian noise on the positive type sample subjected to any three data enhancement operations (the data enhancement operations comprise sharpness, brightness change, color change and tone separation) to construct a constructed Gaussian noise sample image A.
The Gaussian noise sample image is distributed according to the defect distribution diagram
Figure 990790DEST_PATH_IMAGE007
Performing texture display and matching with the positive type sample
Figure 46471DEST_PATH_IMAGE008
Mixing to form an oversubscribed profileTrapping anomalies to obtain an original pseudo-defect image
Figure 613849DEST_PATH_IMAGE009
. Original pseudo-defect image
Figure 413178DEST_PATH_IMAGE009
Is defined as
Figure 596949DEST_PATH_IMAGE010
(1);
Wherein,
Figure 230055DEST_PATH_IMAGE011
is composed of
Figure 143785DEST_PATH_IMAGE012
The inverse of (a) is,
Figure 622170DEST_PATH_IMAGE013
is a point-by-point operation,
Figure 78691DEST_PATH_IMAGE014
is a transparency parameter upon mixing, the parameter being selected from
Figure 85961DEST_PATH_IMAGE015
Interval uniform sampling, i.e.
Figure 877199DEST_PATH_IMAGE016
And A is the constructed Gaussian noise sample image.
Other parts of this embodiment are the same as embodiment 1, and thus are not described again.
Example 3:
this embodiment is further optimized on the basis of the above embodiment 1 or 2, from the original pseudo-defect image
Figure 769063DEST_PATH_IMAGE017
Cutting a small rectangular area with variable size and aspect ratio, randomly rotating the small rectangular area and dithering the pixel value, and then dividing the small rectangular areaThe random position where the fields are pasted to the positive type samples forms a pseudo-defect image, i.e., the negative type samples.
The invention defines a mixnoise operation (sample mixing operation) to generate a negative class sample, which is essentially a data enhancement strategy, and particularly generates a local irregular noise pattern and puts the noise pattern into a positive class sample to try to simulate defect data in real life.
The mixnoise operation (sample mixing operation) proposed by the invention is to obtain the original pseudo-defect image
Figure 329358DEST_PATH_IMAGE017
Cutting a small rectangular area with randomly variable size and aspect ratio, randomly rotating the small rectangular area and dithering pixel values, and then pasting the transformed small rectangular area to a positive sample
Figure 914054DEST_PATH_IMAGE018
Thereby forming a final pseudo-defect image, i.e., a negative type sample, represented as:
Figure 927009DEST_PATH_IMAGE019
wherein, in the process,
Figure 622564DEST_PATH_IMAGE020
in order to be a negative class sample set,
Figure 37365DEST_PATH_IMAGE021
is the nth negative class sample, and n is the number of samples.
The rest of this embodiment is the same as embodiment 1 or 2, and therefore, the description thereof is omitted.
Example 4:
in this embodiment, a comparison learning loss function is used to drive the model to generate positive and negative type sample features that can obviously reflect the existence of defects, so that the normal sample and the negative type sample are separated as much as possible, a larger feature dictionary is maintained by using a momentum comparison method, and the features of the positive and negative type samples are learned while the features are kept consistent.
First, construct a set of negative class samples by a mixnoise operation (sample mixing operation) for each positive class sample
Figure 792962DEST_PATH_IMAGE022
Wherein, in the process,
Figure 293214DEST_PATH_IMAGE020
in order to be a negative class sample set,
Figure 526880DEST_PATH_IMAGE021
for the nth negative sample class, n is the number of samples, and the positive and negative sample class sets are combined to create a sample space
Figure 32073DEST_PATH_IMAGE023
Expressed as:
Figure 958572DEST_PATH_IMAGE024
where n is the number of samples, due to the sample space
Figure 946119DEST_PATH_IMAGE023
Is created by combining positive and negative samples, so that the total number of the samples is 2n, and the random data expansion method is adopted
Figure 983477DEST_PATH_IMAGE025
Two views, namely, the query view and the key view, are generated and then fed into a query network
Figure 107290DEST_PATH_IMAGE026
Heke network (dictionary network)
Figure 204691DEST_PATH_IMAGE027
Obtaining a pair of embedded vectors
Figure 945113DEST_PATH_IMAGE028
And
Figure 532301DEST_PATH_IMAGE029
here, both the query network (query network) and the key network (dictionary network) are Resnet50 networks with classifiers removed, i.e., a common convolutional layer, a BN layer, and a ReLU activation function followed by four residual modules. For query network (query network)
Figure 776201DEST_PATH_IMAGE026
The method has two functions of acquiring embedded vectors and training input data, and for the later functions, the method is applied to a query network (inquiry network)
Figure 778923DEST_PATH_IMAGE026
A classifier-driven model training is added later, represented as:
Figure 741063DEST_PATH_IMAGE031
(2) wherein
Figure 120223DEST_PATH_IMAGE032
is a function of the classification loss for the,
Figure 484208DEST_PATH_IMAGE033
the normal sample is put into a query network (query network) after data enhancement operation, the prediction and the original label are obtained through a classifier to carry out cross entropy operation,
Figure 657831DEST_PATH_IMAGE034
the positive type sample is put into a query network (query network) after being subjected to data enhancement operation by using a negative type sample obtained by mixnoise operation, the prediction and the original label are subjected to cross entropy operation by using a classifier,
Figure 107267DEST_PATH_IMAGE035
for cross entropy loss, for contrast learning, through the query network (query network)
Figure 86856DEST_PATH_IMAGE026
Obtaining the embedded vector of the positive sample with the category of 0 and the rest embedded vectors for comparison learning, firstly constructing a comparison embedded library
Figure 790501DEST_PATH_IMAGE036
And is represented as:
Figure 259659DEST_PATH_IMAGE037
(3);
wherein,
Figure 930812DEST_PATH_IMAGE038
and
Figure 917354DEST_PATH_IMAGE039
is a set of embedded vectors obtained by inputting the query view (query view) and the key view (dictionary view) of all samples of the current batch into a query network (query network) and a key network (dictionary network) respectively,
Figure 990352DEST_PATH_IMAGE040
a queue of embedded vectors, i.e., a feature dictionary, is stored for training. During training, a positive type sample with the category of 0 in the current batch is randomly selected
Figure 771357DEST_PATH_IMAGE018
Embedded vector of, unite
Figure 493588DEST_PATH_IMAGE036
All the positive samples in (1) form a positive sample set
Figure 267509DEST_PATH_IMAGE041
Training a model, a loss function for a specific training
Figure 945746DEST_PATH_IMAGE042
Comprises the following steps:
Figure 146920DEST_PATH_IMAGE043
(4);
wherein,
Figure 277818DEST_PATH_IMAGE044
Figure 589851DEST_PATH_IMAGE045
is a parameter of the temperature of the liquid,
Figure 653753DEST_PATH_IMAGE046
is from a positive sample set
Figure 25828DEST_PATH_IMAGE041
The embedding vector of class 0 obtained in (1),
Figure 909602DEST_PATH_IMAGE047
is an embedded vector obtained from a query network (query network),
Figure 25326DEST_PATH_IMAGE048
is a contrast embedding warehouse
Figure 666436DEST_PATH_IMAGE036
All embedded vectors obtained from the key network (dictionary network);
the overall loss function in the network framework is:
Figure 209413DEST_PATH_IMAGE049
(5);
by using
Figure 49324DEST_PATH_IMAGE050
Parameter updating is carried out on the query network (query network), momentum updating is used by the key network (dictionary network) and the query network (query network) in a joint mode, and the method is represented as follows:
Figure 968739DEST_PATH_IMAGE051
(6);
wherein,
Figure 476074DEST_PATH_IMAGE052
is a parameter of the key network (dictionary network),
Figure 189952DEST_PATH_IMAGE053
is a parameter of the query network (query network),
Figure 48318DEST_PATH_IMAGE054
is a momentum coefficient. Finally, a queue is maintained to store the latest embedded vector
Figure 771424DEST_PATH_IMAGE055
. Adding a classifier driving model after a query network (query network) for training, performing momentum updating by using a key network (dictionary network) and the query network (query network), performing comparative learning according to an embedded vector acquired by the key network (dictionary network) and an embedded vector acquired by the query network (query network), updating the key network (dictionary network) through parameters of the query network (query network), performing comparative learning by combining all embedded vectors output by the two networks, wherein 0/1 prediction output by the classifier can assist in correct defect judgment. Each sample is provided with 0/1 labels, namely a positive sample and a defective negative sample, and is compared with a query network (query network) in a learning network for classification.
Other parts of this embodiment are the same as any of embodiments 1 to 3, and thus are not described again.
Example 5:
in this embodiment, a gaussian density estimator is used to calculate the defect anomaly score so as to determine whether the sample has defects or not. When the defect positioning is carried out on the test sample, the image is divided into image blocks according to a fixed step length, features are extracted from all the image blocks, the abnormal score calculation is carried out on each image block, and the abnormal score is spread to each pixel by using a Gaussian smoothing method. For arbitrary samples
Figure 133266DEST_PATH_IMAGE056
The defect judgment is carried out, and the anomaly detection is realized by using Gaussian density estimation as follows:
Figure 18045DEST_PATH_IMAGE058
(7);
Figure 98128DEST_PATH_IMAGE059
(8);
Figure 359345DEST_PATH_IMAGE060
(9);
wherein is prepared from
Figure DEST_PATH_IMAGE061
And
Figure DEST_PATH_IMAGE062
is the mean and variance obtained from the embedded vectors of the training data, m is the number of selected embedded vectors,
Figure 451060DEST_PATH_IMAGE026
is a query network. The gaussian density estimator can determine whether the image is a defect image. When the image positioning defect is tested, the image is divided into image blocks according to a fixed step length, embedded vectors are extracted from all the image blocks, the abnormal score calculation is carried out on each image block, and the abnormal score is spread to each pixel by using a Gaussian smoothing method.
Other parts of this embodiment are the same as any of embodiments 1 to 4, and thus are not described again.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention in any way, and all simple modifications and equivalent variations of the above embodiments according to the technical spirit of the present invention are included in the scope of the present invention.

Claims (5)

1. A defect detection method based on self-supervision momentum contrast is characterized by comprising the following steps:
step S1, constructing a Gaussian noise sample image as an original pseudo-defect image according to the original positive type sample, the randomly generated mean value and the variance in the data set;
step S2, generating a negative type sample by using a sample mixing operation;
step S3, positive and negative sample characteristics which can obviously reflect the existence of defects are generated by using a contrast learning loss function driving model, so that a normal sample and a negative sample are separated, a characteristic dictionary is maintained by using a momentum contrast method, and the characteristics of the positive and negative samples are learned while the characteristics keep consistency;
and step S4, calculating defect abnormal scores by using a Gaussian density estimator, and judging whether the whole image is a defect image according to the defect abnormal scores to finish defect detection.
2. The method for defect detection based on the auto-supervised momentum contrast as claimed in claim 1, wherein the step S1 includes:
step S11, combining the original positive samples in the data set, and constructing a Gaussian noise sample image by using the randomly generated mean value and variance;
step S12, generating a noise image using a berlin noise generator;
step S13, performing binarization processing on the noise image through a threshold value of uniform random sampling to form a defect distribution map;
and step S14, generating an original pseudo-defect image by combining the normal sample and the Gaussian noise sample according to the defect distribution map.
3. The method for defect detection based on the auto-supervised momentum contrast as claimed in claim 1, wherein the step S2 includes:
randomly selecting a cutting area from an original pseudo-defect image, cutting a small rectangular area with variable size and aspect ratio, randomly rotating the small rectangular area and dithering pixel values, and then pasting the small rectangular area to a random position of a positive sample to form a pseudo-defect image as a negative sample.
4. The method for defect detection based on the auto-supervised momentum contrast as claimed in claim 1, wherein the step S3 includes:
constructing a corresponding negative sample for each positive sample through sample mixing operation, and generating a negative sample set;
combining the positive and negative sample sets to create a sample space;
generating a query view and a dictionary view by a random data expansion method, and sending the query view and the dictionary view into a corresponding query network and a corresponding dictionary network to obtain a pair of embedded vectors q and k;
and adding a classifier driving model after the network is queried for training, performing momentum updating by using the dictionary network and the query network, and performing comparison learning according to the embedded vector acquired by the dictionary network and the embedded vector acquired by the query network.
5. The method for defect detection based on the auto-supervised momentum contrast as claimed in claim 1, wherein the step S4 includes:
when the image positioning defect is tested, dividing the image into image blocks according to a fixed step length, extracting features from all the image blocks, calculating the abnormal score of each image block, and transmitting the calculated abnormal score to each pixel by using a Gaussian smoothing method;
randomly selecting an embedded vector of a sample in a training set to participate in the calculation of a total probability formula;
calculating the mean value and the variance of each embedded vector, and obtaining a total probability formula according to the obtained mean value and variance;
and for the test sample, calculating a defect abnormal score according to a total probability formula, and judging whether the whole image is a defect image according to the defect abnormal score to finish defect detection.
CN202210858635.XA 2022-07-21 2022-07-21 Defect detection method based on self-supervision momentum contrast Active CN115082435B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210858635.XA CN115082435B (en) 2022-07-21 2022-07-21 Defect detection method based on self-supervision momentum contrast

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210858635.XA CN115082435B (en) 2022-07-21 2022-07-21 Defect detection method based on self-supervision momentum contrast

Publications (2)

Publication Number Publication Date
CN115082435A true CN115082435A (en) 2022-09-20
CN115082435B CN115082435B (en) 2022-11-22

Family

ID=83243835

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210858635.XA Active CN115082435B (en) 2022-07-21 2022-07-21 Defect detection method based on self-supervision momentum contrast

Country Status (1)

Country Link
CN (1) CN115082435B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115690094A (en) * 2022-12-12 2023-02-03 常州微亿智造科技有限公司 Industrial defect detection method and system based on self-supervision network

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111982910A (en) * 2020-07-06 2020-11-24 华南理工大学 Weak supervision machine vision detection method and system based on artificial defect simulation
CN112365468A (en) * 2020-11-11 2021-02-12 南通大学 AA-gate-Unet-based offshore wind power tower coating defect detection method
CN112464879A (en) * 2020-12-10 2021-03-09 山东易视智能科技有限公司 Ocean target detection method and system based on self-supervision characterization learning
CN112966755A (en) * 2021-03-10 2021-06-15 深圳市固电电子有限公司 Inductance defect detection method and device and readable storage medium
CN112991330A (en) * 2021-04-19 2021-06-18 征图新视(江苏)科技股份有限公司 Knowledge distillation-based positive sample industrial defect detection method
CN113032458A (en) * 2021-03-23 2021-06-25 中国人民解放军63920部队 Method and device for determining abnormality of spacecraft
CN113313684A (en) * 2021-05-28 2021-08-27 北京航空航天大学 Video-based industrial defect detection system under dim light condition
US20210319266A1 (en) * 2020-04-13 2021-10-14 Google Llc Systems and methods for contrastive learning of visual representations
US20210327029A1 (en) * 2020-04-13 2021-10-21 Google Llc Systems and Methods for Contrastive Learning of Visual Representations
CN114281985A (en) * 2021-09-30 2022-04-05 腾讯科技(深圳)有限公司 Sample feature space enhancement method and device

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20210319266A1 (en) * 2020-04-13 2021-10-14 Google Llc Systems and methods for contrastive learning of visual representations
US20210327029A1 (en) * 2020-04-13 2021-10-21 Google Llc Systems and Methods for Contrastive Learning of Visual Representations
CN111982910A (en) * 2020-07-06 2020-11-24 华南理工大学 Weak supervision machine vision detection method and system based on artificial defect simulation
CN112365468A (en) * 2020-11-11 2021-02-12 南通大学 AA-gate-Unet-based offshore wind power tower coating defect detection method
CN112464879A (en) * 2020-12-10 2021-03-09 山东易视智能科技有限公司 Ocean target detection method and system based on self-supervision characterization learning
CN112966755A (en) * 2021-03-10 2021-06-15 深圳市固电电子有限公司 Inductance defect detection method and device and readable storage medium
CN113032458A (en) * 2021-03-23 2021-06-25 中国人民解放军63920部队 Method and device for determining abnormality of spacecraft
CN112991330A (en) * 2021-04-19 2021-06-18 征图新视(江苏)科技股份有限公司 Knowledge distillation-based positive sample industrial defect detection method
CN113313684A (en) * 2021-05-28 2021-08-27 北京航空航天大学 Video-based industrial defect detection system under dim light condition
CN114281985A (en) * 2021-09-30 2022-04-05 腾讯科技(深圳)有限公司 Sample feature space enhancement method and device

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
KAIMING HE等: "《Momentum Contrast for UnsuperVised Visual Representation Learning》", 《2020 IEEE/CVF CONFERENCE ON COMPUTER VISION AND PATTERN RECOGNITION (CVPR)》 *
张倩等: "《基于自监督表征学习的海面目标检测方法》", 《水下无人系统学报》 *
张玲玲等: "《基于对比约束的可解释小样本学习》", 《计算机研究与发展》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115690094A (en) * 2022-12-12 2023-02-03 常州微亿智造科技有限公司 Industrial defect detection method and system based on self-supervision network

Also Published As

Publication number Publication date
CN115082435B (en) 2022-11-22

Similar Documents

Publication Publication Date Title
CN107330453B (en) Pornographic image identification method based on step-by-step identification and fusion key part detection
CN110852316B (en) Image tampering detection and positioning method adopting convolution network with dense structure
CN109919934B (en) Liquid crystal panel defect detection method based on multi-source domain deep transfer learning
CN112001903A (en) Defect detection network construction method, abnormality detection method and system, and storage medium
CN112183788A (en) Domain adaptive equipment operation detection system and method
CN107169417B (en) RGBD image collaborative saliency detection method based on multi-core enhancement and saliency fusion
CN113870128B (en) Digital mural image restoration method based on depth convolution countermeasure network
CN111027590B (en) Breast cancer data classification method combining deep network features and machine learning model
Christlein et al. A study on features for the detection of copy-move forgeries
CN112686894A (en) FPCB (flexible printed circuit board) defect detection method and device based on generative countermeasure network
CN115082435B (en) Defect detection method based on self-supervision momentum contrast
CN111242026A (en) Remote sensing image target detection method based on spatial hierarchy perception module and metric learning
CN114550110A (en) Vehicle weight identification method and system based on unsupervised domain adaptation
Nirmala et al. A modern approach for image forgery detection using BRICH clustering based on normalised mean and standard deviation
CN114972216A (en) Construction method and application of texture surface defect detection model
CN116188516A (en) Training method of defect data generation model
CN115661539A (en) Less-sample image identification method embedded with uncertainty information
CN114820541A (en) Defect detection method based on reconstructed network
CN117456272A (en) Self-supervision abnormality detection method based on contrast learning
CN117058716A (en) Cross-domain behavior recognition method and device based on image pre-fusion
CN116912144A (en) Data enhancement method based on discipline algorithm and channel attention mechanism
CN116682057A (en) Substation potential safety hazard detection method based on window self-attention mechanism
CN115546689A (en) Video time sequence abnormal frame detection method based on unsupervised frame correlation
CN115409822A (en) Industrial part surface anomaly detection method based on self-supervision defect detection algorithm
CN112861670B (en) Transmission line hardware detection method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant