CN115082435B - 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
CN115082435B
CN115082435B CN202210858635.XA CN202210858635A CN115082435B CN 115082435 B CN115082435 B CN 115082435B CN 202210858635 A CN202210858635 A CN 202210858635A CN 115082435 B CN115082435 B CN 115082435B
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.)
Active
Application number
CN202210858635.XA
Other languages
Chinese (zh)
Other versions
CN115082435A (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)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Multimedia (AREA)
  • Evolutionary Computation (AREA)
  • Computing Systems (AREA)
  • Medical Informatics (AREA)
  • Software Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Databases & Information Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (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 nature of the problem, it is difficult to obtain large amounts of anomaly 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, the training models only learn the existing normal examples, and therefore the training models cannot well determine whether the 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:
s1, constructing a Gaussian noise sample image as an original pseudo-defect image according to an original positive sample, a randomly generated mean value and a variance in a data set;
s2, generating a negative sample by using a sample mixing operation;
s3, generating positive and negative sample characteristics which can obviously reflect the existence of defects by using a comparison learning loss function driving model, separating a normal sample from a defect sample, maintaining a characteristic dictionary by using a momentum comparison method, and learning the characterization of the positive and negative samples while keeping the consistency of the characteristics;
and S4, calculating a defect abnormal score 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 to position defects, extracting features from all the image blocks, calculating an abnormal score for 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 utilizing 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 utilizing a momentum comparison method, and the characteristics of the positive and negative samples are learned while the characteristics keep consistency; 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:
s11, combining the original positive samples in the data set, and constructing a Gaussian noise sample image by using a randomly generated mean value and variance;
step S12, generating a noise image by using a Berlin noise generator;
s13, performing binarization processing on the noise image through a uniformly randomly sampled threshold value to form a defect distribution map;
and 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:
s11, combining the original positive samples in the data set, and constructing a Gaussian noise sample image by using a randomly generated mean value and variance;
step S12, generating a noise image by using a Berlin noise generator;
s13, performing binarization processing on the noise image through a uniformly and randomly sampled threshold value to form a defect distribution map;
and 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 with reference to the following figures and examples, all of which are intended to be covered by the present disclosure and the scope of the invention.
Fig. 1 is a schematic diagram of defect data generation in a defect detection method based on 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, continuity and diversity of the defect data as accurately as possible, the Berlin noise generator is used to generate noise with the same size as the sampleAn acoustic image, a defect distribution diagram is formed by binarization of the noise image through a threshold value of uniform random sampling
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
And 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 the random position of the positive sample to form a pseudo-defect image, namely a negative 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, utilizing a numerical value generated by a random function as a mean value and a variance, utilizing 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 utilizing a Berlin noise generator, performing binarization by using a uniformly randomly sampled threshold value to form a defect distribution diagram, and performing binarization according to defectsAnd the distribution graph generates an original pseudo-defect image by combining the positive type sample and the Gaussian noise sample. 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; and the other method is that the abnormal score is utilized to assist the image in positioning, 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 features are extracted from all the image blocks, the abnormal score is calculated for each image block, and the abnormal score is spread to each pixel by using a Gaussian smoothing method.
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
whereinn is the number of samples in the dataset.
Generating a Perlin noise image (Berlin noise image) P by using a Perlin noise generator (Berlin noise generator), and binarizing the noise image P by uniformly and randomly sampling a threshold value 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 map
Figure 990790DEST_PATH_IMAGE007
Performing texture display and matching with the positive type sample
Figure 46471DEST_PATH_IMAGE008
Mixing to form defect anomalies beyond the distribution 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 the content of the first and second substances,
Figure 230055DEST_PATH_IMAGE011
is composed of
Figure 143785DEST_PATH_IMAGE012
The inverse of (a) is,
Figure 622170DEST_PATH_IMAGE013
is a dot-product operation, and the 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
And cutting a small rectangular area with variable size and aspect ratio, randomly rotating the small rectangular area and dithering a pixel value, 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.
The invention defines a mixnoise operation (sample mixing operation) to generate a negative sample, which is essentially a data enhancement strategy, and particularly generates a local irregular noise pattern and places the local irregular noise pattern into a positive 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 converted 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 step (A),
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.
Other parts of this embodiment are the same as those of embodiment 1 or 2, and thus are not described again.
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, a negative type sample set is constructed for each positive type sample through a mixnoise operation (sample mixing operation)
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 sample space
Figure 946119DEST_PATH_IMAGE023
Is created by combining positive and negative samples, so 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 without classifiers, 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
Has two functions of obtaining embedded vector and training input data, and for the following functions, the invention is applied to query network
Figure 778923DEST_PATH_IMAGE026
A classifier is added later to drive model training, expressed as:
Figure 741063DEST_PATH_IMAGE031
(2) Wherein, in the step (A),
Figure 120223DEST_PATH_IMAGE032
is a function of the loss of the classification,
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, the first and the second end of the pipe are connected with each other,
Figure 930812DEST_PATH_IMAGE038
and
Figure 917354DEST_PATH_IMAGE039
is the query view (query view) and key view of all samples of the current batchThe graph (dictionary view) is respectively input into embedded vector sets obtained by a query network (query network) and a key network (dictionary network),
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 the content of the first and second substances,
Figure 277818DEST_PATH_IMAGE044
Figure 589851DEST_PATH_IMAGE045
is a parameter of the temperature of the liquid crystal,
Figure 653753DEST_PATH_IMAGE046
is from a positive sample set
Figure 25828DEST_PATH_IMAGE041
The embedding vector of class 0 obtained in (c),
Figure 909602DEST_PATH_IMAGE047
is an embedded vector obtained from the query network (query network),
Figure 25326DEST_PATH_IMAGE048
is a contrast embedding warehouse
Figure 666436DEST_PATH_IMAGE036
All the embedding 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
The parameters of the query network (query network) are updated, and the key network (dictionary network) and the query network (query network) are updated by momentum, which is expressed as:
Figure 968739DEST_PATH_IMAGE051
(6);
wherein the content of the first and second substances,
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 behind a query network (inquiry network) for training, performing momentum updating by using a key network (dictionary network) and the query network (inquiry network), and acquiring an embedded vector according to the key network (dictionary network) and an embedded vector acquired by the query network (inquiry network)The input vectors are compared and learned, the key network (dictionary network) is updated through query network (inquiry network) parameters, all embedded vectors output by the two networks are combined for comparison and learning, and the 0/1 prediction output by the classifier can assist in correct defect judgment. Each sample is provided with 0/1 labels, namely a positive class sample and a defective negative class sample, and the query network (inquiry network) in the learning network is compared and classified.
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 test sample is used for defect positioning, an image is divided into image blocks according to a fixed step length, features are extracted from all the image blocks, 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
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 (4)

1. A defect detection method based on self-supervision momentum contrast is characterized by comprising the following steps:
s1, constructing a Gaussian noise sample image as an original pseudo-defect image according to an original positive sample, a randomly generated mean value and a variance in a data set;
s2, generating a negative type sample by using a mixnoise operation;
s3, generating positive and negative sample characteristics which can obviously reflect the existence of defects by using a comparison learning loss function driving model, separating a normal sample from a negative sample, maintaining a characteristic dictionary by using a momentum comparison method, and learning the characterization of the positive and negative samples while keeping the consistency of the characteristics;
s4, calculating a defect abnormal score by using a Gaussian density estimator, and judging whether the whole image is a defect image according to the defect abnormal score to finish defect detection;
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.
2. The method for defect detection based on the auto-supervised momentum contrast as recited in claim 1, wherein the step S1 comprises:
s11, combining the original positive samples in the data set, and constructing a Gaussian noise sample image by using a randomly generated mean value and variance;
step S12, generating a noise image by using a Perlin noise generator;
s13, performing binarization processing on the noise image through a uniformly and randomly sampled threshold value to form a defect distribution map;
and 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 recited in claim 1, wherein the step S2 comprises:
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 comprises:
constructing a corresponding negative type sample for each positive type sample through a mixnoise operation, and generating a negative type sample set;
combining the positive and negative sample sets to create a sample space;
generating a query view and a key view by a random data expansion method, and sending the query view and the key view into a corresponding query network and a corresponding key network to obtain a pair of embedded vectors q and k;
and adding a classifier driving model behind the query network for training, performing momentum updating by using the key network and the query network, and performing comparison learning according to the embedded vector acquired by the key network and the embedded vector acquired by the query network.
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 CN115082435A (en) 2022-09-20
CN115082435B true 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)

Families Citing this family (1)

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

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN113313684A (en) * 2021-05-28 2021-08-27 北京航空航天大学 Video-based industrial defect detection system under dim light condition

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11354778B2 (en) * 2020-04-13 2022-06-07 Google Llc Systems and methods for contrastive learning of visual representations
US11386302B2 (en) * 2020-04-13 2022-07-12 Google Llc Systems and methods for contrastive learning of visual representations
CN111982910B (en) * 2020-07-06 2022-10-25 华南理工大学 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
CN112464879B (en) * 2020-12-10 2022-04-01 山东易视智能科技有限公司 Ocean target detection method and system based on self-supervision characterization learning
CN113032458A (en) * 2021-03-23 2021-06-25 中国人民解放军63920部队 Method and device for determining abnormality of spacecraft
CN114281985A (en) * 2021-09-30 2022-04-05 腾讯科技(深圳)有限公司 Sample feature space enhancement method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN113313684A (en) * 2021-05-28 2021-08-27 北京航空航天大学 Video-based industrial defect detection system under dim light condition

Also Published As

Publication number Publication date
CN115082435A (en) 2022-09-20

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
CN112183788A (en) Domain adaptive equipment operation detection system and method
US11686689B2 (en) Automatic optimization of an examination recipe
CN107169417B (en) RGBD image collaborative saliency detection method based on multi-core enhancement and saliency fusion
CN111027590B (en) Breast cancer data classification method combining deep network features and machine learning model
TW202221536A (en) Generating training data usable for examination of a semiconductor specimen
CN115082435B (en) Defect detection method based on self-supervision momentum contrast
CN114550110A (en) Vehicle weight identification method and system based on unsupervised domain adaptation
CN114972216A (en) Construction method and application of texture surface defect detection model
CN116188516A (en) Training method of defect data generation model
Dalal et al. Autoregressive models: What are they good for?
CN114820541A (en) Defect detection method based on reconstructed network
Li et al. Fabric defect segmentation system based on a lightweight GAN for industrial Internet of Things
CN117058716A (en) Cross-domain behavior recognition method and device based on image pre-fusion
CN113112482A (en) PCB defect detection method based on attention mechanism network
CN115546689A (en) Video time sequence abnormal frame detection method based on unsupervised frame correlation
CN114821174B (en) Content perception-based transmission line aerial image data cleaning method
CN115409822A (en) Industrial part surface anomaly detection method based on self-supervision defect detection algorithm
CN115661539A (en) Less-sample image identification method embedded with uncertainty information
CN111259859B (en) Pedestrian re-recognition method based on combined variable picture generation
CN112861670B (en) Transmission line hardware detection method and system
Ziga et al. Non-parametric texture synthesis using texture classification
Mo et al. Contrastive adaptive frequency decomposition network guided by haze discrimination for real-world image dehazing
TW202022883A (en) Machine continuous learning method of neural network object classifier and related monitoring camera apparatus

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