Film surface flaw image classification method and system
By extracting and fusing the feature vectors of film surface defect images, and combining label embedding and contrastive learning methods, the problem of low classification accuracy in the existing technology is solved, and higher recognition accuracy and classification accuracy are achieved.
Patent Information
- Application Number
- CN202410714100.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-08-30
AI Technical Summary
The existing methods for classifying film surface defect images have low accuracy and are difficult to distinguish between relatively similar categories, resulting in low classification accuracy.
By extracting the direct image feature vector and noise feature vector of the film surface defect image, and using the label embedding vector to train the network model after fusion, combined with the noise prediction network and convolutional network of the image generation model, using the contrastive learning method and the fully connected layer classification head, Improve feature discrimination and classification accuracy.
It improves the recognition accuracy and classification accuracy of film surface defect images, can better distinguish similar defect categories, and enhances the stability and training efficiency of the classification model.
Smart Images

Figure CN118570541A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and in particular to a method and system for classifying film surface defect images. Background Art
[0002] Films used in industrial manufacturing, such as lithium battery coatings, lithium battery separators, aluminum-plastic films, etc., are affected by factors such as the environment and processing technology during the production process. Surface defects such as foreign matter, scratches, particles, poor lamination, and fibers may appear on the surface, affecting the quality of the film. During the film production process, workers need to label and cut the surface defects on the film. Since the size of the defects is small, ranging from a few hundred to a few thousand microns, using industrial cameras to capture defect images and then automatically classify them can help workers deal with defects more efficiently.
[0003] At present, the classification methods of surface defect images can be divided into classification methods based on traditional feature engineering combined with machine learning and classification methods based on deep learning. The classification method based on traditional feature engineering combined with machine learning generally uses feature extraction algorithms, such as SURF features, Gabor filters, histogram features, etc. to extract defect image features to obtain feature vectors, and then uses machine learning methods such as SVM and random forest for classification. This classification method relies on manually selected image features, and it is difficult to fully describe the defect features. The number of categories that can be classified is small, and the classification accuracy is poor. The classification method based on deep learning uses convolutional neural networks, recurrent neural networks and other methods to extract features, and then uses a specific classification head for classification. Although this method has better classification performance than the former method, for the classification task of surface defect images, different types of defects may be very similar. The deep learning method has a strong ability to extract image features, but it cannot directly express the feature differences between images of different categories. For similar categories, it is likely to cause confusion.
[0004] It can be seen that the classification method of surface defect images in the prior art has the problem of low accuracy and difficulty in distinguishing relatively similar categories. Summary of the invention
[0005] The present invention provides a method and system for classifying film surface defect images, so as to solve the problem that the classification method of surface defect images in the prior art has low accuracy and is difficult to distinguish relatively similar categories.
[0006] In order to achieve the above object, the present invention is implemented by the following technical solutions:
[0007] In a first aspect, the present invention provides a method for classifying film surface defect images, comprising:
[0008] S1: pre-processing the collected film surface defect images;
[0009] S2: Determine the label embedding vector corresponding to the preprocessed film surface defect image;
[0010] S3: extracting a direct image feature vector and a noise feature vector of the film surface defect image;
[0011] S4: fusing the direct image feature vector and the noise feature vector to obtain a fused feature vector;
[0012] S5: training a network model based on the label embedding vector and the fused feature vector to obtain a film surface defect image classification model;
[0013] S6: Inputting the film surface defect image subsequently collected in real time into the film surface defect image classification model, and obtaining the classification result output by the film surface defect image classification model.
[0014] In a second aspect, the present application provides a film surface defect image classification system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first aspect when executing the computer program.
[0015] Beneficial effects:
[0016] The film surface defect image classification method provided by the present invention extracts the direct image feature vector and the noise feature vector of the film surface defect image; fuses the direct image feature vector and the noise feature vector to obtain the fused feature vector; determines the film surface defect image classification model according to the label embedding vector; inputs the fused feature vector into the film surface defect image classification model, and obtains the classification result output by the film surface defect image classification model. In this way, the noise prediction network of the image generation model is used as the image feature extractor here to extract the "noise feature" instead of generating the image, and then fuses with the features extracted by another convolutional network, so as to better analyze the features of the film surface defect image and improve the recognition accuracy.
[0017] In a further scheme, since there are situations where different categories of defects in the film surface defect images have high similarity, a label embedding contrast learning method is used. During the training process, the image label is converted into a vector and input into the model to participate in learning and training. The label embedding vector of the category label is used as the center of the fused feature vector of the image belonging to this category, so that the fused feature vectors of images of the same category are more similar, and the feature vectors of images of different categories are more different, which can achieve the effect of improving the feature discrimination of defect images of different categories, thereby improving the ability to distinguish between similar defect image categories and improving the classification accuracy.
[0018] In a further technical solution, not only the feature vector similarity is used as the only indicator for loss calculation, but a fully connected layer classification head is also added to calculate the classification cross entropy loss. The addition of this classification head can ensure the stability of training during the training process, and at the same time can speed up the training of the contrastive learning classification head. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 A flow chart of a method for classifying film surface defect images according to a preferred embodiment of the present invention;
[0020] Figure 2 This is a structural diagram of a label embedding network model of a preferred embodiment of the present invention;
[0021] Figure 3 A noise prediction network model structure diagram of a preferred embodiment of the present invention;
[0022] Figure 4 This is a structural diagram of an LWF model in a preferred embodiment of the present invention;
[0023] Figure 5 This is a model structure diagram of a thin film surface defect image classification method based on feature fusion and label embedding contrast learning according to a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0024] The technical solution of the present invention is described clearly and completely below. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] Unless otherwise defined, the technical terms or scientific terms used in the present invention shall have the usual meanings understood by persons with ordinary skills in the field to which the present invention belongs. The words "first", "second" and similar words used in the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, words such as "one" or "one" do not indicate quantity restrictions, but indicate the existence of at least one. Words such as "connect" or "connected" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the object being described changes, the relative positional relationship also changes accordingly.
[0026] See also Figure 1 The present application provides a method for classifying film surface defect images, comprising:
[0027] S1: pre-processing the collected film surface defect images;
[0028] S2: Determine the label embedding vector corresponding to the preprocessed film surface defect image;
[0029] S3: extracting a direct image feature vector and a noise feature vector of the film surface defect image;
[0030] S4: fusing the direct image feature vector and the noise feature vector to obtain a fused feature vector;
[0031] S5: training a network model based on the label embedding vector and the fused feature vector to obtain a film surface defect image classification model;
[0032] S6: Inputting the film surface defect image subsequently collected in real time into the film surface defect image classification model, and obtaining the classification result output by the film surface defect image classification model.
[0033] In this embodiment, the pre-processing process includes:
[0034] The obtained film surface defect image dataset is preprocessed by grayscale image conversion, horizontal random flipping and regularization.
[0035] The above-mentioned film surface defect image classification method extracts the direct image feature vector and noise feature vector of the film surface defect image; fuses the direct image feature vector and the noise feature vector to obtain a fused feature vector; determines the film surface defect image classification model according to the label embedding vector; inputs the fused feature vector into the film surface defect image classification model, and obtains the classification result output by the film surface defect image classification model. In this way, the noise prediction network of the image generation model is used as the image feature extractor here to extract the "noise feature" instead of generating the image, and then fuses with the features extracted by another convolutional network, so as to better analyze the features of the film surface defect image and improve the recognition accuracy.
[0036] Optionally, the S2 includes:
[0037] Add category labels to the pre-processed film surface defect images;
[0038] Convert the category label into a one-hot encoding vector, and input the one-hot encoding vector into a label embedding network to obtain a label embedding vector output by the label embedding network;
[0039] The label embedding network includes C sub-networks, and each one-hot encoding vector of a category label corresponds to a sub-network.
[0040] In this embodiment, the one-hot encoding vector of the category label is obtained as follows: the dimension of the one-hot encoding vector is equal to the number of categories to be classified C, and the one-hot encoding vector L of the i-th (i∈[1,C]) category label is i The i-th element of is 1, and the rest are 0;
[0041] The label embedding network contains C sub-networks, and each one-hot encoding vector of a category label is passed through a sub-network corresponding to it to obtain a label embedding vector. Specifically, Figure 2 As shown in Figure 1, the subnetwork of the label embedding network is composed of two fully connected layers and a SiLU activation function in between.
[0042] L1, L2…L C For the one-hot encoding vector corresponding to each category label, the one-hot encoding vector of each category label is input into a label embedding network subnetwork consisting of two fully connected layers and the SiLU activation function in the middle. The subnetworks do not share parameters, and the label embedding vector is obtained as follows:
[0043]
[0044] In the formula, represents the label embedding vector corresponding to the encoding vector L1, represents the label embedding vector corresponding to the encoding vector L2, Denotes the encoding vector L C The corresponding label embedding vector.
[0045] Optionally, the S3 includes:
[0046] S31: extracting a direct image feature vector of the film surface defect image through a convolutional neural network branch of the image feature extraction module;
[0047] S32: extracting a noise feature vector of the film surface defect image through a noise feature extraction network branch of the image feature extraction module.
[0048] Wherein, the S32 includes:
[0049] An image generation model is obtained by pre-training based on a training set of film surface defect images collected historically;
[0050] A noise feature extraction network is formed using a noise adding module, the first several layers of the convolutional neural network in the image generation model, and a downsampling layer;
[0051] Set a noise adding times T, input the noise adding times T and the input image x0 into the noise feature extraction network to obtain a noise feature vector;
[0052] The image generation model is a model that generates images by adding noise to the image T times and then denoising the image by predicting the noise distribution;
[0053] The step of adding noise includes: given a noise z~N(0, I), obtaining the image x after the input image x0 is added with noise for the tth time t ; where t∈[1,T];
[0054] The denoising steps include: using the noise prediction network to predict the range from x0 to x t The added noise Then use Get the prediction x of the t-1th noisy image t-1 Repeat this step to get the prediction of the input image x0
[0055] In this embodiment, after the film surface defect image is input into the convolutional neural network branch in the image feature extraction module, a direct image feature vector is obtained. Specifically, the convolutional neural network in the image feature extraction module uses the ResNet34 network; ResNet34 is composed of a convolution module Conv1, a maximum pooling layer, a residual convolution module Conv2_x, a residual convolution module Conv3_x, a residual convolution module Conv4_x, a residual convolution module Conv5_x and an average pooling layer; the convolution module Conv1 includes a 3×3 convolution, a batch normalization layer and a SiLU activation function; the residual convolution modules Conv2_x, Conv3_x, Conv4_x, and Conv5_x are respectively stacked by [3, 4, 6, 3] residual sub-modules; each residual sub-module contains two consecutive convolution modules with the same structure as Conv1; the input feature data is input into the residual sub-module, passes through two convolution modules in turn, and then the obtained features are bitwise added to the input features to obtain the output of the residual sub-module; the film surface defect image is input into the ResNet34 network to obtain a direct image feature vector.
[0056] After the film surface defect image is input into the noise feature extraction network branch in the image feature extraction module, a noise feature vector is obtained; the noise feature extraction network is part of the DDPM image generation model; the DDPM image generation model is composed of a noise addition module, a noise prediction network, and a denoising module; the DDPM image generation model is a model for image generation based on the principle of denoising the image T times and then predicting the noise distribution to perform denoising.
[0057] Specifically, the UNet network is used as the noise prediction network to predict from x0 to x t The added noise The UNet network includes downsampling layers, intermediate layers, and upsampling layers. The input of UNet is t and the image x after t times of noise addition. t ;
[0058] The structure of the noise feature extraction network is referenced Figure 3 , which consists of a noise adding module, a downsampling layer and an intermediate layer of a UNet network, and an average pooling layer; the method for obtaining the noise feature vector of a film surface defect image is:
[0059] First, pre-train the DDPM image generation model on the same training set; the loss function is as follows:
[0060]
[0061] Among them, || || 2 represents the mean square error, Z is the random noise added to x0, is the noise predicted by the UNet model, Loss MSE Make the noise predicted by UNet gradually approach the actual added noise;
[0062] Use the noise adding module, the downsampling layer and the middle layer of UNet, and the average pooling layer to form a noise feature extraction network;
[0063] Select a noise addition number t, input t and the input image x0 into the noise feature extraction network together to obtain the noise feature vector.
[0064] In this embodiment, the noise prediction network of the image generation model is used as the image feature extractor here to extract "noise features" instead of generating images. The image generation model can learn the noise distribution from the noisy image. The noisy image without noise is the original image. Therefore, the characteristics of the noise distribution also reflect the characteristics of the original image to a certain extent. By extracting the middle layer output of the noise prediction network, the noise feature is obtained, and this feature is used to enrich the expression of the defect image features, which can improve the final classification accuracy.
[0065] Optionally, the S4 includes:
[0066] Determine the matrix W of dimension (1, R) f And two sets of training weight matrices W1 and W2;
[0067] The direct image feature vector is dot-multiplied with the weight matrix W1 to obtain the matrix F1, and the noise feature vector is dot-multiplied with the matrix W2 to obtain the matrix F2;
[0068] The matrix F1 is merged with the matrix F2 according to the bitwise multiplication to obtain the matrix F 12 ;
[0069] The matrix F 12 Weighted fusion is performed in its own R direction to obtain a fused feature vector with a dimension of h.
[0070] Specifically, Figure 4 As shown in the figure, the LWF module is used to fuse the direct image feature vector and the noise feature vector to obtain the fused feature vector; the LWF module contains two sets of trainable weight matrices W1 and W2, and a Linear layer; the dimension of matrix W1 is (R, z1, h), the dimension of matrix W2 is (R, z2, h), z1 and z2 are the dimensions of the direct image feature vector and the noise feature vector respectively; the Linear layer contains a matrix W with a dimension of (1, R) f and a bias with dimension (1, h); the feature vector fusion process of the LWF module is:
[0071] The direct image feature vector is dot-multiplied with the weight matrix W1 to obtain the matrix F1, and the noise feature vector is dot-multiplied with the matrix W2 to obtain the matrix F2;
[0072] The matrix F1 is merged with the matrix F2 according to the bitwise multiplication to obtain the matrix F 12 ;
[0073] Matrix F 12 Finally, the features in the R direction are fused through the Linear layer to obtain a fused feature vector with a dimension of h.
[0074] The S5 includes:
[0075] Calculating a cross entropy loss based on the fused feature vector;
[0076] Calculate the cosine similarity between the label embedding vector of each category label and the fused feature vector of the image;
[0077] Calculating contrastive learning loss based on the cosine similarity;
[0078] The total loss of the model is obtained by weighted addition based on the cross entropy loss and the contrastive learning loss, and the total loss is used to update the weight gradient in the model training process to obtain the final film surface defect image classification model; during the training process, the model weight of the noise feature extraction network in the image feature extraction module is frozen. In this embodiment, since the noise feature extraction network is trained in advance under the same data set, there is no need to update the model weight.
[0079] In this embodiment, a film surface defect image classification model is obtained by jointly training a fully connected layer classification head and a contrastive learning classification head, optimizing feature distribution, and verifying the model classification performance according to a preset evaluation method, including the following steps:
[0080] The fully connected layer classification head includes a fully connected layer and a softmax module; the fused feature vector of the film surface defect image is input into the fully connected layer classification head to obtain the predicted probability that the image belongs to each category; the cross entropy loss Loss is calculated based on the predicted probability that the image belongs to each category CE , making the probability of the image belonging to the real category higher and the probability of belonging to other categories lower;
[0081] The contrastive learning classification head includes a similarity calculation module and a loss calculation module. The fused feature vector of the image and the label embedding vectors corresponding to all category labels are input into the similarity module to obtain the similarity between the label embedding vector of each category label and the fused feature vector of the image. Specifically, cosine similarity is used as an indicator to measure the similarity. The calculation method of cosine similarity is:
[0082]
[0083] In the formula, is the label embedding vector of the i-th category, is the fused feature vector of the image, |||| is the vector modulus operation, the value range of cosine similarity is [-1,1], and the larger the cosine similarity, the more similar the two vectors are; the cosine similarity between the label embedding vector of each category label and the fused feature vector of the image is input into the loss calculation module of the contrastive learning classification head, and the contrastive learning loss Loss is calculated according to the following formula contrast :
[0084] Loss contrast =exp(Similarity min -Similarity p );
[0085] In the formula, Loss contrast Represents contrastive learning loss, Similarity min Represents the minimum value of the cosine similarity between the fused feature vector and the label embedding vector of other labels except the true label of the image, Similarity p It is the cosine similarity of the label embedding vector corresponding to the fusion feature vector and the true label of the image. exp represents the exponential function with the natural constant e as the base. Loss contrastThis makes the cosine similarity between the fused feature vector of the image and the label embedding vector of the true category label of the image larger, while the cosine similarity between the fused feature vector of the image and the label embedding vector of other category labels smaller.
[0086] In this embodiment, y=exp(x), y increases monotonically, and as x increases, the growth rate of y becomes faster and faster. min -Similarity p , y = Loss contrast In the early stages of training, Similarity min is relatively large, and Similarity p is relatively small, so the value of x is relatively large. Therefore, the network can obtain a relatively large loss, so that the parameters of the network can be quickly optimized in the early stage of training. In the later stage of training, the value of x is relatively small, and the loss is small, which is conducive to fine-tuning the network parameters.
[0087] The loss of the two classification heads Loss CE With Loss contrast The weighted addition constitutes the total loss of the model, which is used to update the weight gradient during the model training process. During the training process, the model weights of the noise feature extraction network in the image feature extraction module are frozen;
[0088] Specifically, Figure 5 As shown, the overall network structure of this embodiment in the training stage is as follows: the film surface defect image x0 is input into the image feature extraction module composed of the ResNet34 network branch and the noise feature extraction network branch, and the obtained direct image feature vector and noise feature vector are input into the LWF module for feature fusion to obtain the fused feature vector; the fused feature vector is passed through the fully connected classification head to calculate the cross entropy loss Loss CE On the other hand, the cosine similarity between the label embedding vector and the contrastive learning classification head is calculated to calculate the contrastive learning loss Loss contrast .
[0089] After each iteration of training, the classification performance of the model will be verified on the validation set and evaluated according to the preset evaluation method; specifically, the preset evaluation method is:
[0090]
[0091] Among them, Acc is the verification accuracy, TP is the number of images with the correct predicted category, and TN is the number of images with the wrong predicted category;
[0092] The fully connected layer classification head and the contrastive learning classification head are used to calculate Acc respectively, and the one with the larger Acc is selected as the classification head used in the actual prediction, so as to obtain the film surface defect image classification model.
[0093] In this way, since there are situations where different categories of defects in the film surface defect images have high similarity, a label embedding contrast learning method is used. During the training process, the image label is converted into a vector and input into the model to participate in learning and training. The label embedding vector of the category label is used as the center of the fusion feature vector of the image belonging to this category, so that the fusion feature vectors of images of the same category are more similar, and the feature vectors of images of different categories are more different, which can achieve the effect of improving the feature discrimination of defect images of different categories, thereby improving the ability to distinguish between similar defect image categories and improving the classification accuracy.
[0094] In this embodiment, not only the feature vector similarity is used as the only indicator for loss calculation, but also a fully connected layer classification head is added to calculate the classification cross entropy loss. The addition of the classification head can ensure the stability of training during the training process and accelerate the training of the contrastive learning classification head.
[0095] Optionally, the S6 includes:
[0096] Inputting the film surface defect image into the film surface defect image classification model;
[0097] If the film surface defect image classification model uses a fully connected layer classification head, select the category with the highest probability output by the classification head as the predicted category of the input image;
[0098] If the film surface defect image classification model uses a contrastive learning classification head, the category label corresponding to the label embedding vector with the greatest similarity to the fused feature vector of the image is selected as the predicted category of the input image.
[0099] The present application also provides a film surface defect image classification system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first aspect when executing the computer program.
[0100] The film surface defect image classification system can implement various embodiments of the above-mentioned film surface defect image classification method and achieve the same beneficial effects, which will not be described in detail here.
[0101] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A method for classifying film surface defect images, characterized in that: include: S1: pre-processing the collected film surface defect images; S2: Determine the label embedding vector corresponding to the preprocessed film surface defect image; S3: extracting a direct image feature vector and a noise feature vector of the film surface defect image; S4: fusing the direct image feature vector and the noise feature vector to obtain a fused feature vector; S5: training a network model based on the label embedding vector and the fused feature vector to obtain a film surface defect image classification model; S6: Inputting the film surface defect image subsequently collected in real time into the film surface defect image classification model, and obtaining the classification result output by the film surface defect image classification model.
2. The method for classifying film surface defect images according to claim 1, characterized in that: The S2 includes: Add category labels to the pre-processed film surface defect images; Convert the category label into a one-hot encoding vector, and input the one-hot encoding vector into a label embedding network to obtain a label embedding vector output by the label embedding network; The label embedding network includes C sub-networks, and each one-hot encoding vector of a category label corresponds to a sub-network.
3. The method for classifying film surface defect images according to claim 1, characterized in that: The S3 includes: S31: extracting a direct image feature vector of the film surface defect image through a convolutional neural network branch of the image feature extraction module; S32: extracting a noise feature vector of the film surface defect image through a noise feature extraction network branch of the image feature extraction module.
4. The method for classifying film surface defect images according to claim 3, characterized in that: The S32 includes: An image generation model is obtained by pre-training based on a training set of film surface defect images collected historically; A noise feature extraction network is formed using a noise adding module, the first several layers of the convolutional neural network in the image generation model, and a downsampling layer; Set a noise adding times T, input the noise adding times T and the input image x0 into the noise feature extraction network to obtain a noise feature vector; The image generation model is a model that generates images by adding noise to the image T times and then denoising the image by predicting the noise distribution; The step of adding noise includes: given a noise z~N(0, I), obtaining the image x after the input image x0 is added with noise for the tth time t ; where t∈[1,T]; The denoising steps include: using the noise prediction network to predict the range from x0 to x t The added noise Then use Get the prediction x of the t-1th noisy image t-1 Repeat this step to get the prediction of the input image x0 5. The method for classifying film surface defect images according to claim 1, characterized in that: The S4 includes: Determine the matrix W of dimension (1, R) f And two sets of training weight matrices W1 and W2; The direct image feature vector is dot-multiplied with the weight matrix W1 to obtain the matrix F1, and the noise feature vector is dot-multiplied with the matrix W2 to obtain the matrix F2; The matrix F1 is merged with the matrix F2 according to the bitwise multiplication to obtain the matrix F 12 ; The matrix F 12 Weighted fusion is performed in its own R direction to obtain a fused feature vector with a dimension of h.
6. The method for classifying film surface defect images according to claim 1, characterized in that: The S5 includes: Calculating a cross entropy loss based on the fused feature vector; Calculate the cosine similarity between the label embedding vector of each category label and the fused feature vector of the image; Calculating contrastive learning loss based on the cosine similarity; The total loss of the model is obtained by weighted addition of the cross entropy loss and the contrastive learning loss, and the total loss is used to update the weight gradient in the model training process to obtain the final film surface defect image classification model; during the training process, the model weights of the noise feature extraction network in the image feature extraction module are frozen.
7. The method for classifying film surface defect images according to claim 6, characterized in that: The cross entropy loss is calculated to satisfy the following relationship: In the formula, is the label embedding vector of the i-th category, is the fusion feature vector of the image, |||| is the vector modulus operation, and the larger the cosine similarity, the more similar the two vectors are; The calculation contrastive learning loss satisfies the following relationship: Loss contrast =exp(Similarity min -Similarity p ); In the formula, Loss contrast Represents contrastive learning loss, Similarity min Represents the minimum value of the cosine similarity between the fused feature vector and the label embedding vector of other labels except the true label of the image, Similarity p It is the cosine similarity between the fused feature vector and the label embedding vector corresponding to the true label of the image, and exp represents an exponential function with the natural constant e as the base.
8. The method for classifying film surface defect images according to claim 6, characterized in that: The method of using the total loss to perform weight gradient updating in the model training process to obtain a final film surface defect image classification model includes: After each iteration of training, the classification performance of the model is verified on the validation set and evaluated according to the preset evaluation method; Among them, the preset evaluation method is as follows: Among them, Acc is the verification accuracy, TP is the number of images with the correct predicted category, and TN is the number of images with the wrong predicted category; The fully connected layer classification head and the contrastive learning classification head are used to calculate Acc respectively, and the one with the larger Acc is selected as the classification head used in the actual prediction, so as to obtain the film surface defect image classification model.
9. The method for classifying film surface defect images according to claim 8, characterized in that: The S6 includes: Inputting the film surface defect image into the film surface defect image classification model; If the film surface defect image classification model uses a fully connected layer classification head, select the category with the highest probability output by the classification head as the predicted category of the input image; If the film surface defect image classification model uses a contrastive learning classification head, the category label corresponding to the label embedding vector with the greatest similarity to the fused feature vector of the image is selected as the predicted category of the input image.
10. A film surface defect image classification system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Multi-task long-tail distribution image recognition method and system, electronic equipment and medium
CN113449613A
Counterfeit image recognition method, device and equipment and storage medium
CN113869419A
Deep counterfeit image detection method and system fused with noise perception
CN114677372A
Multi-modal data-based heavy balance long-tail image data classification method
CN115205592A
CG image detection method based on double-flow neural network channel combination and soft pooling
CN115410029A
Cited By
Pipeline leakage detection method and device
CN121435159A
Method and apparatus for detecting leaks in a pipeline
CN121435159B
