A complex texture and pattern color difference detection method based on self-supervised contrastive learning

Through the method based on self-supervised comparison learning, the labeled data set is constructed and data enhancement is carried out, the feature extraction ability is improved, the subjectivity and false detection of existing chromatic aberration detection methods are solved, and the chromatic aberration detection with high accuracy and speed is achieved.

CN114723707BActive Publication Date: 2025-04-29GUANGDONG UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210362124.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-07
Publication Date
2025-04-29
Estimated Expiration
2042-04-07

AI Technical Summary

Technical Problem

The existing chromatic aberration detection methods are highly subjective, and the detection of adjacent chromatic aberration levels is easy to be mis-checked, and the traditional template matching method is slow to process and has low accuracy.

Method used

The complex texture and pattern chromatic aberration detection method based on self-supervised contrast learning is adopted to construct the original data set with labels, and data enhancement is performed, and the encoder and projection network are used for pre-training, feature extraction capabilities are improved, and the classification network is connected to the classification network for detection.

Benefits of technology

It realizes objective and accurate chromatic aberration detection, solves the problems of large subjectivity and misdetection of adjacent chromatic aberration levels, and improves the detection speed and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114723707B_ABST
    Figure CN114723707B_ABST
Patent Text Reader

Abstract

The invention relates to the field of industrial detection technology, and discloses a complex texture and pattern color difference detection method based on self-supervised contrast learning, comprising the following steps: S1. constructing a labeled original data set; S2. performing data enhancement on the original data set to obtain an enhanced data set; S3. extracting image features of the enhanced data set through an encoder; S4. projecting the image features of the enhanced data through a projection network to obtain an embedding vector; S5. calculating the similarity between different images in the enhanced data set and the pre-trained contrast loss according to the obtained embedding vector, and improving the encoder according to the contrast loss; S6. connecting a classification network behind the improved encoder, replacing the projection network, reacquiring the improved image features through the improved encoder, and classifying and detecting the images in the enhanced data set. The invention solves the problem that the prior art is highly subjective and the detection of adjacent color difference levels is prone to misdetection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of industrial detection technology, and more specifically, to a complex texture and pattern color difference detection method based on self-supervised contrast learning. Background Art

[0002] The methods for evaluating the color difference quality of color prints mainly include: visual inspection, densitometry, and colorimetry. The subjective visual inspection method is a method of evaluating printed products based on the perception of the human eye. The subjective visual inspection method mainly relies on direct comparison between the set standard printed sheets and the production samples to analyze the visual color difference between the two, and uses magnification tools to observe the shape changes of various color dots and the dot overprinting to make a comprehensive evaluation. The density detection method is based on the ink layer thickness of the printed product. The density value directly reflects the reflectivity of the printed product, thereby directly judging the depth of the printed color and the thickness of the ink layer, affecting the regulation and control of printing production. For a long time, the density detection method has been widely used by printing companies for quality inspection, but there are obvious differences in the consistency of different instruments, which is not suitable for widespread use. The colorimetric detection method is a detection method that measures the color information of printed products. It is a basic research tool for printing companies to use object color, measure color, and describe color. Since colorimetric detection is not affected by subjective factors, it can objectively display the detection measurement, but it cannot be directly associated with the ink layer thickness, dot changes, etc., so the detection data is directly used to guide production. Density detection method and colorimetric detection method overcome various problems of subjective detection method and determine similar measurement reference. However, since most industrial printed products have complex textures or patterns, and density and colorimetric detection are calculated based on fixed models, the relevant test reflections cannot meet the universality and accuracy. In addition, the two detection methods can only read the value detection within the 10 square millimeter area of ​​the printed sample. Therefore, it is necessary to build a color difference detection model for complex texture and pattern images based on the saliency algorithm. At present, the highest resolution of corrugated paper digital printing machine can print 1200×600 images, and the pattern texture is fine and complex. If the traditional template matching method is used for color difference detection, grading and color separation and other tasks, the processing speed is slow and the accuracy is low.

[0003] To solve this problem, there is a self-supervised image classification method based on contrastive learning, which includes the following steps: step S1: obtain unlabeled data and perform random enhancement to generate different views; step S2: extract features of the views, calculate the loss by unsupervised contrast, and obtain an unsupervised classification model C1; step S3: manually annotate part of the unlabeled data as a training verification set; step S4: use C1 as a pre-trained model and perform fine-tuning according to the training verification set; step S5: extract features of the training verification set, calculate the loss by supervised contrast, and obtain C2; step S6: predict labels for unlabeled data according to C2, and select data with confidence higher than a preset value as training samples; step S7: based on the training samples, use C2 as a pre-trained model, select a small network for training and fine-tuning, and use the model with the highest verification output accuracy as the best classification model C3.

[0004] However, the existing color difference detection method has the problem of high subjectivity and easy misdetection of adjacent color difference levels. Therefore, how to invent an objective and highly accurate color difference detection method is an urgent problem to be solved in the field of this technology. Summary of the invention

[0005] In order to solve the problem that the prior art is highly subjective and detection of adjacent color difference levels is prone to misdetection, the present invention provides a complex texture and pattern color difference detection method based on self-supervised contrast learning, which is objective and highly accurate.

[0006] In order to achieve the above-mentioned purpose of the present invention, the technical scheme adopted is as follows:

[0007] A complex texture and pattern color difference detection method based on self-supervised contrast learning comprises the following steps:

[0008] S1. Get the original image and construct a labeled original data set according to the color difference grading standard;

[0009] S2. Perform data enhancement on the original data set to obtain an enhanced data set;

[0010] S3. Start pre-training and extract image features of the enhanced dataset through the encoder;

[0011] S4. Projecting the image features of the enhanced data through a projection network to obtain an embedding vector;

[0012] S5. Based on the obtained embedding vector, calculate the similarity between different images in the enhanced dataset and the contrast loss of pre-training, and improve the encoder based on the contrast loss, and end the pre-training;

[0013] S6. Connect a classification network behind the improved encoder to replace the projection network, reacquire the improved image features through the improved encoder, and perform classification detection on the images in the enhanced dataset.

[0014] Preferably, step S1 comprises the following specific steps:

[0015] S101. Collecting N sample image data sets with a resolution of w×h from the object to be analyzed;

[0016] S102. Label each sample image according to the color difference classification standard, and record the original data set as I = {I 1 , I 2 ,......,I N}.

[0017] Further, step S2, the specific steps are:

[0018] S201. Divide the original data set into several batches with a batch size of n, and transform them through the transformation function R T :

[0019] R T =random(flip,rotate,crop,zoom)

[0020] Perform data augmentation on the original sample image data in batches, where random represents a random selection function, flip represents a flip transformation, rotate represents a rotation transformation, crop represents a crop transformation, and zoom represents a zoom transformation;

[0021] S202. Each sample image I in each batch of data sets i Randomly select two types of enhancement transformations for enhancement in turn through random functions;

[0022] S203. Output is an enhanced data set with a quantity of 2N and a resolution of w×h.

[0023] Furthermore, the encoder extracts the image features of the enhanced dataset. The specific steps are:

[0024] A01. Through the convolution layer, the resolution is w×h and the number of channels is C input The enhanced image processing is Tensor C with 64 channels 1 :

[0025] C 1 =Conv 7_2 (C input )

[0026] Among them, Conv7_2 Indicates that the convolution kernel size of the convolution layer is 7 and the convolution kernel step size is 2;

[0027] A02. Tensor C 1 The feature map C is obtained by passing the batch normalization layer and the activation function layer in turn. 2 ,

[0028] C 2 =Act ReLU (BN(C 1 ))

[0029] Among them, BN represents the batch normalization layer, Act ReLU represents the activation function;

[0030] A03. The feature map C 2 After the maximum pooling layer, the shape obtained is The feature map C 3 :

[0031] C 3 =MaxP 3_2 (C 2 )

[0032] Among them, MaxP 3_2 Indicates the maximum pooling layer with a pooling kernel size of 3 and a pooling kernel stride of 2;

[0033] A04. Feature Map C 3 After passing through the four residual learning stages of Stage1, Stage2, Stage3, and Stage4, the image feature vector H is obtained:

[0034] Stage 1: C 4 =BTK 2 (BTK 2 (BTK 1 (C 3 )))

[0035] Stage 2: C 5 =BTK 2 (BTK 2 (BTK 2 (BTK 1 (C 4 ))))

[0036] Stage 3: C 6 =BTK 2 (BTK 2 (BTK 2 (BTK 2 (BTK 2 (BTK 1 (C 5))))))

[0037] Stage 4: H = BTK 2 (BTK 2 (BTK 1 (C 6 )))

[0038] Among them, BTK 1 () represents the I-type bottleneck block of the residual structure, BTK 2 () represents the type II bottleneck block of the residual structure, C 4 is the feature map obtained after the residual learning stage Stage 1, C 5 is the feature map obtained after the residual learning stage Stage2, C 6 is the feature map obtained after the residual learning stage Stage3, and H is the m-dimensional feature vector obtained after the residual learning stage Stage4.

[0039] Furthermore, the image features of the enhanced data are projected through the projection network to obtain the embedded vector. Specifically, H is input into the projection network that realizes nonlinear transformation. The process expression is as follows:

[0040] z=FC(Act ReLU (Dense(H)))

[0041] Among them, FC is the fully connected layer, and z is the embedded vector obtained by projection representation.

[0042] Furthermore, based on the obtained embedding vector, the similarity between different images in the enhanced dataset and the pre-trained contrast loss are calculated, specifically:

[0043] B01. By enhancing any two enhanced images A in the dataset i and A j The embedding vector z i and z j , calculate two enhanced images A i and A j The cosine similarity between:

[0044]

[0045] Among them, σ is an adjustable parameter used to scale the input and expand the range of cosine similarity [-1, 1], ||z i || and ||z j || represents the modulus of the embedding vector;

[0046] B02. Pair similar cosine similarities and calculate the noise contrast estimation loss l(i, j):

[0047]

[0048] Where k is the function count value;

[0049] B03. When the image positions are swapped, the contrast estimation loss l(j, i) of the same pair of images is calculated again:

[0050]

[0051] B04. Calculate the loss of all pairs with batch size n and take the average to get the contrast loss L N :

[0052]

[0053] B05. According to L N Fix the encoder weights and end pre-training.

[0054] Furthermore, the classification network includes three Dense blocks, which are modules including several layers, wherein the feature map of each layer has the same size; in the classification network, the image features of the enhanced data pass through a convolution layer, then through three Dense blocks in turn, then through a pooling layer and a linear function layer, and then the result is output, and two adjacent Dense blocks are connected by a convolution layer and a pooling layer.

[0055] Furthermore, the process of the image feature x of the enhanced data passing through the Dense block is:

[0056] f 1 =Conv 1_1 (Act ReLU (BN(x)))

[0057] f 2 =Conv 3_1 (Act ReLU (BN(f 1 )))

[0058] Among them, Conv 1_1 and Conv 3_1 They represent the convolutional layer with a kernel size of 1 and a stride of 1 and the convolutional layer with a kernel size of 3 and a stride of 1, respectively. 1 is the feature map after 1×1 convolution processing, f 2 It is the feature map after 3×3 convolution processing.

[0059] Furthermore, to classify and detect the images in the enhanced dataset, it is also necessary to calculate the loss of the classification network and train the classification network based on the loss of the classification network; the loss function of the classification network is Ld for:

[0060]

[0061] Where T is the number of color difference levels, y n is a label, if the color difference level of the current sample is n, y n =1, otherwise 0, p n is the probability that the color difference level of the current sample is n.

[0062] A complex texture and pattern color difference detection system based on self-supervised contrast learning includes a data acquisition module, a data enhancement module, an encoder, a projection network module, and a classification network module; the data acquisition module is used to acquire original images and construct a labeled original data set according to a color difference classification standard, the encoder is used to obtain image features of enhanced data, the projection network module is used to project image features through a projection network, and the classification network module is used to classify color differences to obtain color difference detection classification results.

[0063] The beneficial effects of the present invention are as follows:

[0064] After collecting and collating the original data set, the present invention enhances the original data set, and pre-trains the encoder in combination with the projection operation through the enhanced data set, thereby improving the feature extraction capability of the encoder, and realizes the detection of complex texture and pattern color difference by accessing a classification network instead of a projection network, thereby solving the problem of high subjectivity and easy misdetection of adjacent color difference levels in the prior art, and having the characteristics of objectivity and high accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] Figure 1 This is a flowchart of the complex texture and pattern color difference detection method based on self-supervised contrast learning.

[0066] Figure 2 This is a schematic diagram of the image feature flow of the encoder extracting the enhanced data set in the complex texture and pattern color difference detection method based on self-supervised contrast learning in Example 2.

[0067] Figure 3 It is a schematic diagram of a type I bottleneck block and a type II bottleneck block in the complex texture and pattern color difference detection method based on self-supervised contrast learning in Example 2.

[0068] Figure 4 This is a flow chart of the classification network in the complex texture and pattern color difference detection method based on self-supervised contrast learning.

[0069] Figure 5 This is a schematic diagram of the Dense block of the classification network in the complex texture and pattern color difference detection method based on self-supervised contrastive learning. DETAILED DESCRIPTION

[0070] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.

[0071] Example 1

[0072] like Figure 1 As shown, a complex texture and pattern color difference detection method based on self-supervised contrast learning includes the following steps:

[0073] S1. Get the original image and construct a labeled original data set according to the color difference grading standard;

[0074] S2. Perform data enhancement on the original data set to obtain an enhanced data set;

[0075] S3. Start pre-training and extract image features of the enhanced dataset through the encoder;

[0076] S4. Projecting the image features of the enhanced data through a projection network to obtain an embedding vector;

[0077] S5. Based on the obtained embedding vector, calculate the similarity between different images in the enhanced dataset and the contrast loss of pre-training, and improve the encoder based on the contrast loss, and end the pre-training;

[0078] S6. Connect a classification network behind the improved encoder to replace the projection network, reacquire the improved image features through the improved encoder, and perform classification detection on the images in the enhanced dataset.

[0079] Example 2

[0080] like Figure 1 As shown, a complex texture and pattern color difference detection method based on self-supervised contrast learning includes the following steps:

[0081] S1. Get the original image and construct a labeled original data set according to the color difference grading standard;

[0082] S2. Perform data enhancement on the original data set to obtain an enhanced data set;

[0083] S3. Start pre-training and extract image features of the enhanced dataset through the encoder;

[0084] S4. Projecting the image features of the enhanced data through a projection network to obtain an embedding vector;

[0085] S5. Based on the obtained embedding vector, calculate the similarity between different images in the enhanced dataset and the contrast loss of pre-training, and improve the encoder based on the contrast loss, and end the pre-training;

[0086] S6. Connect a classification network behind the improved encoder to replace the projection network, reacquire the improved image features through the improved encoder, and perform classification detection on the images in the enhanced dataset.

[0087] In a specific embodiment, step S1 comprises the following steps:

[0088] S101. Collect N sample image data sets with a resolution of w×h from the object to be analyzed; in this embodiment, collect 600 sample image data sets with a resolution of 576×576 from a printing production line.

[0089] S102. Label each sample image according to the color difference classification standard, and record the original data set as I = {I 1 , I 2 ,......,I N}.

[0090] Step S2, the specific steps are:

[0091] S201. Divide the original data set into several batches with a batch size of n, and transform them through the transformation function R T :

[0092] R T =random(flip,rotate,crop,zoom)

[0093] Data enhancement is performed on the original sample image data in batches, where random represents a random selection function, flip represents a flip transformation, rotate represents a rotation transformation, crop represents a crop transformation, and zoom represents a zoom transformation; in this embodiment, the original data set is divided into several batches with a batch size of 6;

[0094] S202. Each sample image I in each batch of data sets i Randomly select two types of enhancement transformations for enhancement in turn through random functions;

[0095] S203. Output is an enhanced data set with a quantity of 2N and a resolution of w×h.

[0096] In this embodiment, after each batch of data sets is input into the data enhancement module, each sample image I in the batch iTwo types of enhancement transformations will be randomly selected through random functions. Since the transformation function will not change the color difference characteristics of the sample, the enhancement results of the same sample have the same color difference characteristics and should eventually be classified into the same color difference level by the classification network. After the first round of data enhancement operations, all batches will output an enhanced data set with a quantity of 1200 and a resolution of 576×576.

[0097] In this embodiment, an enhanced data set with a resolution of 576×576 and a channel number of C is input into an untrained initial encoder. The process can be expressed as:

[0098] H=Extract(A)

[0099] The function of Extract() includes obtaining the image features of the sample data through the encoder and converting A ij The image representation is converted into an m-dimensional vector H ij The encoder used in the pre-training process includes a deep learning network module consisting of two parts: feature extraction and residual module.

[0100] like Figure 2 , 3 As shown, the encoder extracts the image features of the enhanced data set. The specific steps are:

[0101] A01. Through the convolution layer, the resolution is w×h and the number of channels is C input The enhanced image processing is Tensor C with 64 channels 1 :

[0102] C 1 =Conv 7_2 (C input )

[0103] Among them, Conv 7_2 Indicates that the convolution kernel size of the convolution layer is 7 and the convolution kernel step size is 2;

[0104] A02. Tensor C 1 The feature map C is obtained by passing the batch normalization layer and the activation function layer in turn. 2 ,

[0105] C 2 =Act ReLU (BN(C 1 ))

[0106] Among them, BN represents the batch normalization layer, Act ReLU represents the activation function;

[0107] A03. The feature map C 2After the maximum pooling layer, the shape obtained is The feature map C 3 :

[0108] C 3 =MaxP 3_2 (C 2 )

[0109] Among them, MaxP 3_2 Indicates the maximum pooling layer with a pooling kernel size of 3 and a pooling kernel stride of 2;

[0110] A04. In the residual module, there are two bottleneck blocks with different residual structures. The I-type bottleneck block has two important adjustable parameters λ and μ. λ is responsible for controlling whether to perform downsampling, and μ is responsible for controlling whether to reduce the number of channels. The specific operation is to achieve the purpose of different input channels and output channels through the convolution layer on the residual branch. There is no convolution layer on the residual branch of the II-type bottleneck block, so the number of output channels and the number of input channels remain the same. The entire residual module can be divided into four residual learning stages with the I-type bottleneck block as the boundary. The feature map C 3 After passing through the four residual learning stages of Stage1, Stage2, Stage3, and Stage4, the image feature vector H is obtained:

[0111] Stage 1: C 4 =BTK 2 (BTK 2 (BTK 1 (C 3 )))

[0112] Stage 2: C 5 =BTK 2 (BTK 2 (BTK 2 (BTK 1 (C 4 ))))

[0113] Stage 3: C 6 =BTK 2 (BTK 2 (BTK 2 (BTK 2 (BTK 2 (BTK 1 (C 5 ))))))

[0114] Stage 4: H = BTK 2 (BTK 2 (BTK 1 (C 6 )))

[0115] Among them, BTK 1 () represents the I-type bottleneck block of the residual structure, BTK 2 () represents the type II bottleneck block of the residual structure, C 4 is the feature map obtained after the residual learning stage Stage 1, C 5 is the feature map obtained after the residual learning stage Stage2, C 6 is the feature map obtained after the residual learning stage Stage3, and H is the m-dimensional feature vector obtained after the residual learning stage Stage4. In this embodiment, the Stage1 residual learning includes sequentially passing through 2 type II bottleneck blocks and 1 type I bottleneck block, the stage2 residual learning includes sequentially passing through 1 type I bottleneck block and 3 type II bottleneck blocks, the stage3 residual learning includes sequentially passing through 1 type I bottleneck block and 5 type II bottleneck blocks, and the stage4 residual learning includes sequentially passing through 1 type I bottleneck block and 2 type II bottleneck blocks.

[0116] In this embodiment, in the first stage, the feature extraction module outputs a feature map C of shape (64, 144, 144). 3 When inputting, considering that the sample image input has just been convolved and max pooled in the feature extraction module, and residual learning has not yet been performed, direct downsampling will lose a lot of information. In addition, the number of input channels is 64 at this time, and there is no need to reduce the number of channels to improve learning efficiency. Therefore, both λ and μ remain in the default state of not performing operations. After the first stage of residual learning, the next three stages can directly set downsampling and reduce the number of channels to further improve the learning efficiency of the model.

[0117] The image features of the enhanced data are projected through the projection network to obtain the embedded vector. Specifically, H is input into the projection network that realizes nonlinear transformation. The process expression is as follows

[0118] z=FC(Act ReLU (Dense(H)))

[0119] Among them, FC is a fully connected layer, which is used to extract the association between features and finally map them to the output space. z is the embedded vector obtained by the projection representation, which is used for pre-training loss calculation.

[0120] In a specific embodiment, the similarity between different images in the enhanced dataset and the pre-trained contrast loss are calculated based on the obtained embedding vector, specifically:

[0121] B01. By enhancing any two enhanced images A in the dataset i and A j The embedding vector z i and zj , calculate two enhanced images A i and A j The cosine similarity between:

[0122]

[0123] Among them, σ is an adjustable parameter used to scale the input and expand the range of cosine similarity [-1, 1], ||z i || and ||z j || represents the modulus of the embedding vector; the above formula is used to calculate the pairwise cosine similarity between each enhanced image in the batch. Ideally, the similarity between enhanced images of the same color difference level will be very high, that is, when the embedding vector subscript i=j, a higher cosine similarity will be calculated.

[0124] B02. Pair similar cosine similarities and calculate the noise contrast estimation loss l(i, j):

[0125]

[0126] Where k is the function count value;

[0127] B03. When the image positions are swapped, the contrast estimation loss l(j, i) of the same pair of images is calculated again:

[0128]

[0129] B04. Calculate the loss of all pairs with batch size n and take the average to get the contrast loss L N :

[0130]

[0131] B05. According to L N Fix the encoder weights and end pre-training. N ,The encoder and projection head representations improve over time, and the obtained representations place similar images closer together in space.

[0132] Example 3

[0133] like Figure 1 As shown, a complex texture and pattern color difference detection method based on self-supervised contrast learning includes the following steps:

[0134] S1. Get the original image and construct a labeled original data set according to the color difference grading standard;

[0135] S2. Perform data enhancement on the original data set to obtain an enhanced data set;

[0136] S3. Start pre-training and extract image features of the enhanced dataset through the encoder;

[0137] S4. Projecting the image features of the enhanced data through a projection network to obtain an embedding vector;

[0138] S5. Based on the obtained embedding vector, calculate the similarity between different images in the enhanced dataset and the contrast loss of pre-training, and improve the encoder based on the contrast loss, and end the pre-training;

[0139] S6. Connect a classification network behind the improved encoder to replace the projection network, reacquire the improved image features through the improved encoder, and perform classification detection on the images in the enhanced dataset.

[0140] In a specific embodiment, step S1 comprises the following steps:

[0141] S101. Collecting N sample image data sets with a resolution of w×h from the object to be analyzed;

[0142] S102. Label each sample image according to the color difference classification standard, and record the original data set as I = {I 1 , I 2 ,......,I N}.

[0143] Step S2, the specific steps are:

[0144] S201. Divide the original data set into several batches with a batch size of n, and transform them through the transformation function R T :

[0145] R T =random(flip,rotate,crop,zoom)

[0146] Perform data augmentation on the original sample image data in batches, where random represents a random selection function, flip represents a flip transformation, rotate represents a rotation transformation, crop represents a crop transformation, and zoom represents a zoom transformation;

[0147] S202. Each sample image I in each batch of data sets i Randomly select two types of enhancement transformations for enhancement in turn through random functions;

[0148] S203. Output is an enhanced data set with a quantity of 2N and a resolution of w×h.

[0149] In a specific embodiment, the encoder extracts the image features of the enhanced data set by:

[0150] A01. Through the convolution layer, the resolution is w×h and the number of channels is C input The enhanced image processing is Tensor C with 64 channels 1 :

[0151] C 1 =Conv 7_2 (C input )

[0152] Among them, Conv 7_2 Indicates that the convolution kernel size of the convolution layer is 7 and the convolution kernel step size is 2;

[0153] A02. Tensor C 1 The feature map C is obtained by passing the batch normalization layer and the activation function layer in turn. 2 ,

[0154] C 2 =Act ReLU (BN(C 1 ))

[0155] Among them, BN represents the batch normalization layer, Act ReLU represents the activation function;

[0156] A03. The feature map C 2 After the maximum pooling layer, the shape obtained is The feature map C 3 :

[0157] C 3 =MaxP 3_2 (C 2 )

[0158] Among them, MaxP 3_2 Indicates the maximum pooling layer with a pooling kernel size of 3 and a pooling kernel stride of 2;

[0159] A04. Feature Map C 3 After passing through the four residual learning stages of Stage1, Stage2, Stage3, and Stage4, the image feature vector H is obtained:

[0160] Stage 1: C 4 =BTK 2 (BTK 2 (BTK 1 (C 3 )))

[0161] Stage 2: C 5 =BTK 2 (BTK2 (BTK 2 (BTK 1 (C 4 ))))

[0162] Stage 3: C 6 =BTK 2 (BTK 2 (BTK 2 (BTK 2 (BTK 2 (BTK 1 (C 5 ))))))

[0163] Stage 4: H = BTK 2 (BTK 2 (BTK 1 (C 6 )))

[0164] Among them, BTK 1 () represents the I-type bottleneck block of the residual structure, BTK 2 () represents the type II bottleneck block of the residual structure, C 4 is the feature map obtained after the residual learning stage Stage 1, C 5 is the feature map obtained after the residual learning stage Stage2, C 6 is the feature map obtained after the residual learning stage Stage3, and H is the m-dimensional feature vector obtained after the residual learning stage Stage4.

[0165] The image features of the enhanced data are projected through the projection network to obtain the embedded vector. Specifically, H is input into the projection network that realizes nonlinear transformation. The process expression is as follows

[0166] z=FC(Act ReLU (Dense(H)))

[0167] Among them, FC is the fully connected layer, and z is the embedded vector obtained by projection representation.

[0168] In a specific embodiment, the similarity between different images in the enhanced dataset and the pre-trained contrast loss are calculated based on the obtained embedding vector, specifically:

[0169] B01. By enhancing any two enhanced images A in the dataset i and A j The embedding vector z i and z j , calculate two enhanced images A i and A j The cosine similarity between:

[0170]

[0171] Among them, σ is an adjustable parameter used to scale the input and expand the range of cosine similarity [-1, 1], ||z i || and ||z j || represents the modulus of the embedding vector;

[0172] B02. Pair similar cosine similarities and calculate the noise contrast estimation loss l(i, j):

[0173]

[0174] Where k is the function count value;

[0175] B03. When the image positions are swapped, the contrast estimation loss l(j, i) of the same pair of images is calculated again:

[0176]

[0177] B04. Calculate the loss of all pairs with batch size n and take the average to get the contrast loss L N :

[0178]

[0179] B05. According to L N Fix the encoder weights and end pre-training.

[0180] like Figure 4 As shown, in a specific implementation, the classification network includes three Dense blocks, and the Dense block is a module including several layers, wherein the feature map of each layer has the same size; in the classification network, the image features of the enhanced data pass through a convolution layer and then through three Dense blocks in turn, and then through a pooling layer and a linear function layer to output the result, and two adjacent Dense blocks are connected by a convolution layer and a pooling layer to reduce the size of the feature map, thereby playing the role of a compression model.

[0181] In this embodiment, the Dense block is a module including many layers, the feature maps of each layer have the same size, and dense connections are used between layers.

[0182] like Figure 5 As shown, in a specific implementation, the process of the image feature x of the enhanced data passing through the Dense block is:

[0183] f 1 =Conv 1_1 (Act ReLU (BN(x)))

[0184] f 2 =Conv 3_1 (Act ReLU (BN(f 1 )))

[0185] Among them, Conv 1_1 and Conv 3_1 They represent the convolutional layer with a kernel size of 1 and a stride of 1 and the convolutional layer with a kernel size of 3 and a stride of 1, respectively. 1 is the feature map after 1×1 convolution processing, f 2 It is the feature map after 3×3 convolution processing.

[0186] In a specific implementation, the images in the enhanced data set are classified and detected, and the loss of the classification network needs to be calculated, and the classification network is trained according to the loss of the classification network; the function L of the loss of the classification network d for:

[0187]

[0188] Where T is the number of color difference levels, y n is a label, if the color difference level of the current sample is n, y n =1, otherwise 0, p n is the probability that the color difference level of the current sample is n.

[0189] After collecting and collating the original data set, the present invention enhances the original data set, and pre-trains the encoder in combination with the projection operation through the enhanced data set, improves the feature extraction capability of the encoder, and realizes the detection of complex texture and pattern color difference by accessing a classification network instead of a projection network; the present invention solves the problems of slow speed and low detection accuracy of adjacent color difference levels in traditional color difference detection methods through the idea of ​​self-supervised contrast learning, and on the other hand, compared with the supervised learning method, the present invention can be more suitable for scenes with a small number of samples, and uses the advantages of contrast learning to solve the problem of requiring a large amount of labeled data in supervised learning, greatly improving the generalization performance of the model, and has the characteristics of high detection accuracy, strong detection robustness, and wide applicability.

[0190] Example 4

[0191] A complex texture and pattern color difference detection system based on self-supervised contrast learning includes a data acquisition module, a data enhancement module, an encoder, a projection network module, and a classification network module; the data acquisition module is used to acquire original images and construct a labeled original data set according to a color difference classification standard, the encoder is used to obtain image features of enhanced data, the projection network module is used to project image features through a projection network, and the classification network module is used to classify color differences to obtain color difference detection classification results.

[0192] Obviously, the above embodiments of the present invention are only examples for clearly explaining the present invention, and are not intended to limit the implementation methods of the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention shall be included in the protection scope of the claims of the present invention.

Claims

1. A complex texture and pattern color difference detection method based on self-supervised contrast learning, characterized by: The following steps are involved: S1. Get the original image and construct a labeled original dataset according to the color difference grading standard; S2. Perform data augmentation on the original data set to obtain an augmented data set; S3. Start pre-training and extract image features of the enhanced dataset through the encoder; S4. Projecting the image features of the enhanced data through a projection network to obtain an embedding vector; S5. Based on the obtained embedding vector, calculate the similarity between different images in the enhanced dataset and the contrast loss of pre-training, and improve the encoder based on the contrast loss, and end the pre-training; S6. Connect a classification network behind the improved encoder to replace the projection network, reacquire the improved image features through the improved encoder, and perform classification detection on the images in the enhanced dataset; The classification network includes three Dense blocks, which are modules including several layers, wherein the feature maps of each layer have the same size; in the classification network, the image features of the enhanced data pass through a convolution layer, then through three Dense blocks in sequence, then through a pooling layer and a linear function layer, and then the result is output, and two adjacent Dense blocks are connected by a convolution layer and a pooling layer; The process of the image feature x of the enhanced data passing through the Dense block is: in, and They represent the convolution layer with a kernel size of 1 and a stride of 1 and the convolution layer with a kernel size of 3 and a stride of 1. is the feature map after 1×1 convolution processing, It is the feature map after 3×3 convolution processing.

2. The complex texture and pattern color difference detection method based on self-supervised contrast learning according to claim 1, characterized in that: Step S1, the specific steps are: S101. Collect the number of , the resolution is A sample image dataset of S102. Label each sample image according to the color difference classification standard, and record the original data set as .

3. The complex texture and pattern color difference detection method based on self-supervised contrast learning according to claim 2, characterized in that: Step S2, the specific steps are: S201. The original data set is divided into batches of size Divide into several batches and pass the transformation function : Perform data augmentation on the original sample image data in batches, where random represents a random selection function, flip represents a flip transformation, rotate represents a rotation transformation, crop represents a crop transformation, and zoom represents a zoom transformation; S202. Each sample image in each batch of data sets Randomly select two types of enhancement transformations for enhancement in turn through random functions; S203. The output quantity is , the resolution is The enhanced dataset.

4. The complex texture and pattern color difference detection method based on self-supervised contrast learning according to claim 3, characterized in that: The encoder extracts the image features of the enhanced dataset. The specific steps are: A01. Through the convolution layer, the resolution is , the number of channels is The enhanced image processing is A tensor with 64 channels : in, The convolution kernel size of the convolution layer is , the convolution kernel step size is ; A02. Tensor The feature map is obtained by passing the batch normalization layer and the activation function layer in turn. , in, represents a batch normalization layer, represents the activation function; A03. The feature map After the maximum pooling layer, the shape obtained is Feature map : in, Indicates the maximum pooling layer with a pooling kernel size of 3 and a pooling kernel stride of 2; A04. Feature map Pass in sequence , , , Four residual learning stages, the image feature vector H is obtained: in, A type I bottleneck block representing the residual structure, A type II bottleneck block representing the residual structure, The feature map obtained after the residual learning stage Stage1, It is the feature map obtained after the residual learning stage Stage2 is the feature map obtained after the residual learning stage Stage3, and H is the m-dimensional feature vector obtained after the residual learning stage Stage4.

5. The complex texture and pattern color difference detection method based on self-supervised contrast learning according to claim 4, characterized in that: The image features of the enhanced data are projected through the projection network to obtain the embedded vector, specifically: Input into the projection network that implements nonlinear transformation, the process expression is as follows: in, Fully connected layers, is the embedding vector obtained by the projection representation.

6. The complex texture and pattern color difference detection method based on self-supervised contrast learning according to claim 5, characterized in that: According to the obtained embedding vector, the similarity between different images in the enhanced dataset and the pre-training contrast loss are calculated, specifically: B01. By enhancing any two enhanced images in the dataset and The embedding vector and , calculate two enhanced images and The cosine similarity between: in, is an adjustable parameter used to scale the input and expand the range of cosine similarity to [-1,1]. and represents the modulus of the embedding vector; B02. Pair similar cosine similarities and calculate noise contrast estimation loss : Where k is the function count value; B03. Calculate the contrast estimation loss for the same pair of images again with the images swapped : ; B04. Calculate the loss of all pairs with batch size n and take the average to get the contrast loss : B05. According to Encoder weights, ending pre-training.

7. The complex texture and pattern color difference detection method based on self-supervised contrast learning according to claim 6, characterized in that: To classify and detect images in the enhanced dataset, it is also necessary to calculate the loss of the classification network and train the classification network based on the loss of the classification network; the function of the loss of the classification network is for: Where T is the number of color difference levels, is a label, if the color difference level of the current sample is n, , otherwise 0, is the probability that the color difference level of the current sample is n.

8. A complex texture and pattern color difference detection system based on self-supervised contrast learning, characterized by: Used to execute the complex texture and pattern color difference detection method based on self-supervised contrast learning as described in any one of claims 1 to 7, comprising a data acquisition module, a data enhancement module, an encoder, a projection network module, and a classification network module; The data acquisition module is used to collect original images and construct a labeled original data set according to the color difference grading standard. The encoder is used to obtain the image features of the enhanced data. The projection network module is used to project the image features through the projection network. The classification network module is used to classify the color difference to obtain the color difference detection grading result.

Citation Information

Patent Citations

  • Image Semantic Segmentation Method Based on Deep Full Convolutional Network and Conditional Random Field

    AU2020103901A4

  • Self-supervised image classification method based on comparative learning

    CN112381116A