Impurity detection method based on semi-supervised learning and computer program product

The semi-supervised learning approach for impurity detection in cash crop production lines addresses clustering issues and enhances accuracy by using labeled and unlabeled data with pseudo-labels and data augmentation, improving detection efficiency and reducing manual labeling.

CN119167204APending Publication Date: 2024-12-20SENINT(SUZHOU) TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411209456.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

Current unsupervised algorithms for impurity detection in cash crop production lines suffer from clustering degradation, incomplete classification of impurity morphologies, and high probabilities of missed and false detections due to noise and interference, leading to low accuracy in identifying various impurities.

Method used

An impurity detection method based on semi-supervised learning, utilizing a first sample set with raw material labels and a second unlabeled sample set to calculate association relationships, update weight parameters, and apply pseudo-labels for improved detection accuracy, incorporating data augmentation techniques to enhance training data.

Benefits of technology

Enhances detection accuracy for known and unknown impurities by leveraging labeled and unlabeled data, reducing manual labeling efforts and improving generalization and robustness of the impurity detection model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119167204A_ABST
    Figure CN119167204A_ABST
Patent Text Reader

Abstract

The invention discloses an impurity detection method based on semi-supervised learning and a computer program product, and relates to the technical field of computer vision detection. The impurity detection method based on semi-supervised learning comprises the following steps: pre-constructing an impurity detection model, specifically, obtaining a first sample set Ai and a second sample set Bj; and predicting the second sample set Bj according to the first sample set Ai, and taking the most confident prediction result as a pseudo label of the second sample set Bj. Calculating an association relationship between the first sample set Ai and the second sample set Bj; a target distribution function is obtained according to the association relationships, and when the association relationships are inconsistent, the probability of the target distribution function is zero; and calculating correlation loss of the first sample set Ai and the second sample set Bj, and updating weight parameters of the impurity detection model. By adopting the technology provided by the invention, the manual marking cost can be effectively reduced, and the detection accuracy of unknown impurities can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer vision detection, and in particular to an impurity detection method based on semi-supervised learning and a computer program product. Background Art

[0002] It is inevitable that impurities will be mixed into the raw materials production line during the processing of cash crops (such as tobacco). The types of impurities are mainly divided into three categories: Class A impurities include rubber, plastic fibers, animal feathers, metal objects, etc.; Class B impurities include paper scraps, rope ends, hemp pieces, stones, etc.; Class C impurities include plants and non-raw material plant fibers, etc.

[0003] Based on this, some production lines currently use unsupervised algorithms to detect and identify the above impurities, but unsupervised algorithms have the following problems: First, clustering degradation, that is, during the clustering process, some clusters are too large and dominant or other clusters tend to disappear (usually encountered in center-based clustering algorithms such as k-means); second, in the clustering method based on mutual information maximization, due to the entropy maximization component in the mutual information, all images are assigned to the same class, and the loss will not be minimized; third, noise data and unknown or interference data may have a negative impact on the clustering results, resulting in a decrease in clustering performance. This leads to a low accuracy rate in the model's recognition of impurities, making it difficult to meet the screening requirements of various impurities.

[0004] In addition, due to the incomplete classification of impurity morphology, the pre-classification list of impurities cannot cover all impurity morphologies, and in the current visible light image, the morphology of impurities is similar to the characteristics of raw materials, resulting in a high probability of missed detection and false detection using the above-mentioned unsupervised algorithm. Summary of the invention

[0005] The present invention provides an impurity detection method and a computer program product based on semi-supervised learning to solve the problem that the prior art cannot cover all impurity types, resulting in a high probability of missed detection and false detection.

[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is to provide an impurity detection method based on semi-supervised learning, and the impurity detection method based on semi-supervised learning includes: Pre-build the impurity detection model, specifically: Get the first sample set and the second sample set , wherein the first sample set is raw material label data, and the second sample set is no raw material label data According to the first sample set For the second sample set Make a prediction and use the most confident prediction result as the second sample set 's pseudo-labels.

[0007] Calculate the first sample set and the second sample set ; obtaining a target distribution function according to the association relationship, wherein when the association relationship is inconsistent, the probability of the target distribution function is zero; calculating the first sample set and the second sample set The association loss is calculated and the weight parameters of the impurity detection model are updated; wherein, when the first sample set The labels and the second sample set When the pseudo-label does not match, the corresponding first sample set is set To the second sample set The transition probability is zero.

[0008] The technical solution provided by the present invention has the following beneficial effects compared with the prior art: By using the first sample set with raw material labels To train the impurity detection model, that is, when inspecting the actual raw material production line, the identification target will be determined as the raw material, so there is no need to enumerate the types and shapes of impurities, thereby reducing the difficulty of manual labeling operations.

[0009] Among them, the first sample set with raw material labels through supervised learning , to achieve the second unlabeled sample set The semi-supervised training can effectively improve the generalization ability and detection accuracy of the impurity detection model. And the similarity between the first sample set with raw material labels and the second sample set without raw material labels is determined by calculating the association relationship (for example, the similarity in the embedding space).

[0010] In addition, the target distribution function encourages the impurity detection model to learn consistency, such as high correlation when the association is consistent and low correlation when it is inconsistent. and the second sample set The correlation loss between them can improve the detection accuracy of unknown impurities.

[0011] In some embodiments, the calculation of the first sample set and the second sample set The association relationship includes: defining the first sample set and the second sample set The similarity matrix , recorded as:

[0012] Then the first sample set and the second sample set The conversion probability of the association relationship is:

[0013] in, The function is defined as:

[0014] Then the first sample set To the second sample set Then to the first sample set The probability of the association is:

[0015] Wherein, k represents the first sample set and the second sample set The embedding dimension of .

[0016] Using the above technical solution, analyze the first sample set With the second sample set The similarity in the embedding space enables the model to improve the detection accuracy of the impurity detection model for unknown types of impurities based on a small amount of image data with raw material labels and a large amount of image data without raw material labels.

[0017] In some embodiments, obtaining a target distribution function according to the association relationship includes: defining a target distribution function as:

[0018] Among them, when the corresponding sample is composed of the first sample set Enhanced to the second sample set , and then the second sample set Enhanced to the first sample set , the probability that the labels of the corresponding samples are inconsistent is zero.

[0019] In some embodiments, the calculation of the first sample set and the second sample set The association loss is calculated and the weight parameters of the impurity detection model are updated, including: Defining the association loss , recorded as:

[0020] in, represents cross entropy.

[0021] Using the above technical solution, the impurity detection model is encouraged to find the weights that convert the input image into an embedding so that the embedding of images of the same type remains consistent.

[0022] In some embodiments, the first sample set For the second sample set Make a prediction and use the most confident prediction result as the second sample set Pseudo labels include: Embed the first sample set , recorded as:

[0023] in, Represents the original image The embedding set of .

[0024] Calculating classification loss , and obtain the centroid variable The second sample set is embedded with The relationship between Denoted as:

[0025] Where k represents the number of clusters, Represents the centroid variable and has a label.

[0026] In some embodiments, the first sample set For the second sample set Make a prediction and use the most confident prediction result as the second sample set The pseudo labels also include: Embedding Augmented Images , recorded as:

[0027] in, Represents enhanced image The embedding set of Represents a collection of enhancement methods. ; Calculating classification loss , recorded as:

[0028] in, Represents the original image The embedding set of Represents the associated loss.

[0029] In some embodiments, the calculation of the first sample set and the second sample set The associated loss and updating the weight parameters of the impurity detection model also include: According to the weight parameter Map to ,in, represents the center of gravity variable, Represents the original image The embedding set of Represents enhanced image The embedding set of Represents cluster distribution; according to The function converts the output of the impurity detection model into a probability distribution; calculates the classification loss function , and update the weight parameters.

[0030] In some embodiments, the first sample set For the second sample set Make a prediction and use the most confident prediction result as the second sample set The pseudo labels also include: Define the enhanced loss function as:

[0031] in, represents the cross entropy, Represents the original image The logit value of Represents enhanced image The logit value of .

[0032] In some embodiments, the obtaining of the first sample set and the second sample set Also includes: For the first sample set Perform data enhancement, specifically: Get the original image , where the original image For labeled data.

[0033] From the original image Randomly crop a part of the area and then crop it out as the enhanced image ; Randomly flip the original image horizontally or vertically , as the enhanced image ; To the original image Add Gaussian noise as an enhanced image ; For the original image Perform a small angle rotation as an enhanced image ; Adjust the original image Brightness, saturation and hue as a way to enhance the image ; Wherein, the enhanced image With the original image The labels are consistent.

[0034] By adopting the above technical solution, the first labeled data set can be effectively expanded through one or more operations combined with each other to modify the original image.

[0035] In some embodiments, the present application also provides a computer program product, including a computer program / instruction, which implements the above-mentioned impurity detection method based on semi-supervised learning when the computer program / instruction is executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work, among which: Figure 1 This is a schematic diagram of an embodiment of an impurity detection method provided by the present invention. Figure 1 ; Figure 2 It is a flow chart of an embodiment of an impurity detection method provided by the present invention; Figure 3 This is a schematic diagram of an embodiment of an impurity detection method provided by the present invention. Figure 2 ; Figure 4 This is a production line shot of an embodiment of an impurity detection method provided by the present invention; Figure 5 This is a decolorized impurity type atlas of an embodiment of an impurity detection method provided by the present invention. DETAILED DESCRIPTION

[0037] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0038] See also Figure 1 and Figure 2 As shown, Figure 1 A schematic diagram showing a process of an embodiment of an impurity detection method provided by the present application is shown in Figure 1 ; Figure 2 A flow chart of an embodiment of an impurity detection method provided by the present application is shown.

[0039] In some embodiments, the impurity detection method based on semi-supervised learning includes pre-building an impurity detection model, and the specific steps are: Step S100, obtaining a first sample set and the second sample set .

[0040] For example, the first sample set For raw material label data, the second sample set No raw material label data The first sample set The first sample set may be a normal sample that is manually labeled, or may also include an enhanced sample. The number of samples is smaller than the second sample set .

[0041] In the process of screening raw materials on the production line, since the types and forms of impurities cannot be exhaustively listed, it is difficult to fully cover and identify all impurities, so the identification can be simply divided into two categories, namely, judging impurities or raw materials. Among them, this application does not limit the identification type. For example, according to actual needs, impurities can be further subdivided into multiple categories, such as Class A, Class B and Class C, etc., to meet different detection accuracy requirements.

[0042] Step S200: Based on the first sample set For the second sample set Make predictions and use the most confident predictions as the second sample set 's pseudo-labels.

[0043] Specifically, the impurity detection model includes a neural network model, which uses the feedback mechanism of the neural network model to detect the first sample set. After supervised learning, the second sample set can be predicted The corresponding pseudo labels can be used to further train the impurity detection model, thereby improving the generalization ability of the impurity detection model to classify raw materials, main impurities and unknown impurities.

[0044] For example, based on the word embedding method in natural language processing (NLP), the first sample set and the second sample set The second sample set Introducing embedding design, that is, defining a mapping relationship to map the raw material image to a fixed-width embedding in the HWC (H stands for height, W stands for width, and C stands for the number of channels) dimension, so as to facilitate the subsequent establishment of the first sample set With the second sample set The association relationship between them in the embedding space.

[0045] Step S300, calculating the first sample set and the second sample set The associated relationship.

[0046] Specifically, define the first sample set and the second sample set The similarity matrix , recorded as:

[0047] The first sample set and the second sample set The conversion probability of the association relationship is:

[0048] Among them, the first sample set is transformed into and the second sample set The similarity problem between them is converted into a probability distribution. The function is defined as:

[0049] Convert the first sample set and the second sample set The correlation direction of the first sample set To the second sample set The conversion probability of the associated relationship transforms the second sample set To the first sample set The conversion probability, that is, the transposition of M is , where T represents transpose.

[0050] So the first sample set To the second sample set Then to the first sample set The probability of the associated loop is:

[0051] Among them, k represents the first sample set and the second sample set For example, the default embedding dimension of the image is set to 128 dimensions.

[0052] The first sample set is calculated by the above and the second sample set to facilitate the analysis of the first sample set With the second sample set The similarity in the embedding space makes it possible to improve the detection accuracy of the impurity detection model for unknown types of impurities based on a small number of image data with raw material labels and a large number of image data without raw material labels during the recognition process.

[0053] For example, the second sample set Indicates that according to the association relationship, it is determined that it is related to the first sample set , and then assign the most similar label as the pseudo label.

[0054] Step S400, obtaining a target distribution function according to the association relationship.

[0055] Specifically, the target distribution function is defined as:

[0056] The associated loop (i.e. the corresponding samples from the first sample set To the second sample set , and then from the second sample set To the first sample set ) are inconsistent, the probability of the target distribution function is zero. In other words, when a labeled sample is transferred and then returned to the original sample set, if the label of the sample is inconsistent (that is, the labels of the first state i, the second state j and the third state k of the sample are inconsistent), the probability of this situation is set to zero. Among them, the association loop refers to the sample in the first sample set and the second sample set The process of transfer between.

[0057] The transition probability can be understood as a measure of the similarity between labeled samples and unlabeled samples in the embedding space. When the labeled samples are similar to the unlabeled samples, the transition probability is high, otherwise the transition probability is low. The labels and the second sample set When the pseudo-label does not match, the corresponding first sample set is set To the second sample set The transition probability of is zero. Exemplarily, when it has high similarity, the impurity detection model also learns to make the first sample set With the second sample set The embedding vector is close to .

[0058] Step S500, calculating the first sample set and the second sample set The association loss is calculated and the weight parameters of the impurity detection model are updated.

[0059] Specifically, the design association loss function is recorded as:

[0060] in, Represents cross entropy. By combining the cross entropy loss to train the impurity detection model, the feature representation when the above-mentioned association loop is inconsistent can be reduced. For example, the cross entropy loss is , where P and Q represent two probability distributions defined on the same probability space, represents the true probability, represents the predicted probability of the impurity detection model.

[0061] Using the above association loss function This encourages the impurity detection model to find the weights to convert the input image into an embedding, so that multiple images of the same type are embedded in a consistent manner, thereby achieving classification of impurities in the image. Among them, when the cross entropy loss is applied to binary classification (raw materials and impurities), it can directly measure the unlabeled second sample set The probability distribution of the predicted pseudo-labels and the first sample set The gap between the probability distribution of the true labels.

[0062] In the embodiment of the present application, by using the first sample set with raw material labels To train the impurity detection model, that is, when inspecting the actual raw material production line, after marking a small amount of raw material samples, the classification between raw material samples and impurities can be realized. That is, the identification target is determined as the raw material, so there is no need to exhaustively enumerate the types and shapes of impurities, reducing the difficulty of manual labeling operations. Exemplarily, the impurity types can also be further classified, for example, when performing the labeling operation, adding labeling for some impurity types.

[0063] Among them, the first sample set with raw material labels through supervised learning , to achieve the second unlabeled sample set The semi-supervised training can effectively improve the generalization ability and detection accuracy of the impurity detection model. And the similarity between the first sample set with raw material labels and the second sample set without raw material labels is determined by calculating the association relationship (for example, the similarity in the embedding space).

[0064] In addition, the target distribution function encourages the impurity detection model to learn consistency, such as high correlation when the association relationship is consistent and low correlation when it is inconsistent. And by minimizing the association loss between the first sample set and the second sample set, the detection accuracy is improved.

[0065] For example, in some application scenarios, a camera captures images of raw materials on a production line, and the impurity detection model performs feature detection on the captured raw material images to identify known impurities, unknown impurities and raw materials. For example, the detected impurities may be selected according to pixel coordinates.

[0066] In some embodiments, step S300, based on the first sample set For the second sample set Make predictions and use the most confident predictions as the second sample set Pseudo labels include: Embedding the first sample set , recorded as:

[0067] in, Represents the original image The embedding set of , R represents a real number, Represents a 128-dimensional real vector. Represents a mapping relationship, for example, an image dimension HWC is mapped to an embedding of a fixed width. For example, the number of channels C is three RGB channels.

[0068] For example, the embedding adopts Euclidean normalization , the first sample set , the second sample set The L2 norm of each sample in is normalized to between 0 and 1. The normalization is defined as: .

[0069] Calculating classification loss , and obtain the centroid variable and embed the second sample set The relationship between Denoted as:

[0070] Where k represents the number of clusters, Represents the centroid variable and has a label.

[0071] For example, the introduced centroid variables represent the center point of each cluster. For example, in K-means clustering, the centroid variable represents the mean of all image embedding vectors in the cluster. The dimension of the centroid variable is the same as the first sample set. and the second sample set In addition, the subscript range of the centroid variable is 0 to K-1, which is used to index each cluster.

[0072] In some implementation schemes, step S100, obtaining a first sample set The first sample set may include Perform data augmentation, for example, by taking one or more of the following steps.

[0073] (1) From the original image Randomly crop a part of the area and then crop it out as the enhanced image ; Randomly flip the original image horizontally or vertically , as the enhanced image . (2) To the original image Add Gaussian noise as an enhanced image ; (3) For the original image Perform a small angle rotation as an enhanced image ; (4) Adjust the original image Brightness, saturation and hue as a way to enhance the image .

[0074] Among them, the enhanced image With the original image The labels are consistent, thereby increasing the training data of the impurity detection model and improving its robustness.

[0075] Combination Figure 3 As shown, Figure 3 A schematic diagram showing a process of an embodiment of an impurity detection method provided by the present application is shown in Figure 2 .

[0076] In some embodiments, step S300, based on the first sample set For the second sample set Make predictions and use the most confident predictions as the second sample set The pseudo labels also include: Step S210: pre-acquire the original image .

[0077] Step S210, the original image Perform image enhancement and obtain enhanced image , specifically: Embedding Augmented Images , recorded as:

[0078] in, Represents enhanced image The embedding set of Represents a collection of enhancement methods. ; Calculating classification loss , recorded as:

[0079] in, Represents the original image The embedding set of Represents the associated loss.

[0080] In the embodiment of the present application, since labeled sample data requires the use of special equipment or manual labeling through an expensive and time-consuming experimental process to obtain, the introduction of image enhancement can reduce the number of samples that require manual labeling.

[0081] For example, when the above four methods are used to enhance the original image, four enhancement results with shared labels (the labels of the original image and the enhanced image are the same) can be obtained, thereby greatly increasing the number of trainable samples to improve the recognition results of the impurity detection model for raw materials, major impurities and unknown impurities.

[0082] In each iteration of the model, each sample image of the raw material is not used separately for operation, but is grouped (for example, the first sample set As a group), after calculating the loss, divide the accumulated loss value by the first sample set The total number of samples (such as the number of superimposed original images and enhanced images) is used to obtain the average loss, and then the parameters of the model are updated based on the average loss using gradient descent or other optimization algorithms, thereby improving the overall performance of the raw material detection model.

[0083] Step S220, calculate the loss function , specifically: Define the enhancement loss function , recorded as:

[0084] in, represents the cross entropy, Represents the original image The logit value of Represents enhanced image The logit value of .

[0085] The logit value is the inverse of the logistic function, which is used to map the probability to a real value in an infinite range. The logit value can be any real value. When the logit value is positive, it means that it tends to be classified into this category. When the logit value is negative, it means that it tends not to be classified into this category. For example, when there are only two categories, it tends to be classified into the impurity category or the raw material category.

[0086] Integrate the original image and the enhanced image into the first sample set Supervised learning can significantly improve the robustness of the impurity detection model to input disturbances and reduce overfitting.

[0087] In some embodiments, step S500, calculate the first sample set and the second sample set The associated loss is calculated and the weight parameters of the impurity detection model are updated, including: According to the weight parameter Map to ,in, represents the center of gravity variable, Represents the original image The embedding set of Represents enhanced image The embedding set of Represents cluster distribution. For example, when the centroid variable is introduced When , the output of the fully connected layer is the corresponding centroid variable .

[0088] according to The function converts the output of the impurity detection model into a probability distribution.

[0089] Calculate the classification loss function , and update the weight parameters of the fully connected layer.

[0090] Through the softmax operation, each logit vector can be interpreted as the probability of belonging to a certain cluster. Combined with the classification loss function And the above enhancement loss , where the classification loss function is the cross entropy loss function. Through optimization algorithms such as back propagation and gradient descent, the weight parameters of the fully connected layer are updated to minimize the overall loss of the impurity detection model.

[0091] Combination Figure 4 As shown, Figure 4 A production line shot (decolorized) of an embodiment of an impurity detection method provided by the present application is shown; Figure 5 A decolorized impurity type atlas of an embodiment of an impurity detection method provided by the present application is shown, wherein RGB three-channel color images are mainly used in actual production.

[0092] In some application scenarios, the constructed test set is used to test the impurity detection model. When the evaluated impurity detection model meets the requirements of the production environment (for example, it meets the detection requirements for Class A impurities), the impurity prediction model is deployed and connected to the camera equipment on the production line, so that the real-time raw material images taken by the camera equipment can be used as the input of the impurity detection model (such as Figure 4 As shown). For example, the raw material production line can be reflected by a reflector, and then the reflector can be photographed by a camera device, thereby improving the coverage of the camera's field of view.

[0093] In some embodiments, the present application also provides a computer program product, including a computer program / instruction, which implements the above-mentioned impurity detection method based on semi-supervised learning when the computer program / instruction is executed by a processor.

[0094] It should be understood by those skilled in the art that the embodiments of the present invention can be provided as methods, systems or computer program products. Those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

[0095] The above description is only an implementation mode of the present invention, and does not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the present invention specification and drawings, or directly or indirectly used in other related technical fields, should be included in the protection scope of the present invention.

Claims

1. A method for impurity detection based on semi-supervised learning, characterized in that: include: Pre-built impurity detection model, specifically: Get the first sample set A i and the second sample set B j , wherein the first sample set A i is data with raw material labels, and the second sample set is data without raw material labels; According to the first sample set A i For the second sample set B j Make a prediction and use the most confident prediction result as the second sample set B j Pseudo labels of Calculate the first sample set A i and the second sample set B j The relationship between Acquire a target distribution function according to the association relationship, wherein when the association relationship is inconsistent, the probability of the target distribution function is zero; Calculate the first sample set A i and the second sample set B j The association loss is calculated, and the weight parameters of the impurity detection model are updated; Among them, when the first sample set A i The label and the second sample set B j When the pseudo-labels do not match, the corresponding first sample set A is set i To the second sample set B j The transition probability is zero.

2. The impurity detection method based on semi-supervised learning according to claim 1, characterized in that: The calculation of the first sample set A i and the second sample set B j The associated relationships include: Define the first sample set A i and the second sample set B j The similarity matrix M ij , recorded as: M ij :=A i ·B j Then the first sample set A i and the second sample set B j The conversion probability of the association relationship is: Among them, the softmax(x) function is defined as: Then the first sample set A i To the second sample set B j Then to the first sample set A i The probability of the association is: Wherein, k represents the first sample set A i and the second sample set B j The embedding dimension of .

3. The impurity detection method based on semi-supervised learning according to claim 2, characterized in that: The acquiring of the target distribution function according to the association relationship comprises: Define the target distribution function as: Among them, when the corresponding sample is composed of the first sample set A i Enhanced to the second sample set B j , and then the second sample set B j Enhanced to the first sample set A i , the probability that the labels of the corresponding samples are inconsistent is zero.

4. The impurity detection method based on semi-supervised learning according to claim 3, characterized in that: The calculation of the first sample set A i and the second sample set B j The association loss is calculated and the weight parameters of the impurity detection model are updated, including: Define the association loss L assoc , recorded as: Among them, crossentropy represents cross entropy.

5. The impurity detection method based on semi-supervised learning according to claim 1, characterized in that: According to the first sample set A i For the second sample set B j Make a prediction and use the most confident prediction result as the second sample set B j Pseudo labels include: Embed the first sample set A i , recorded as: f(x i )=z i Among them, z i Represents the original image x i The embedding set z i ∈R 128 ; Calculate classification loss Loss assoc,c , and obtain the center of gravity variable μ k The second sample set B is embedded with j The relationship between assoc,c Denoted as: Loss assoc,c =Let go assoc (μ k ,z i ) Among them, k represents the number of clusters, μ k represents the centroid variable and has a label.

6. The impurity detection method based on semi-supervised learning according to claim 5, characterized in that: According to the first sample set A i For the second sample set B j Make a prediction and use the most confident prediction result as the second sample set B j The pseudo labels also include: Embed augmented image x j , recorded as: z j =f(τ(x j )) Among them, z j Represents the enhanced image x j The embedding set of τ(x j ) represents the set of enhancement methods, z j ∈R 128 ; Calculate classification loss Loss assoc,aug , recorded as: Loss assoc,aug =Loss assoc (z i ,f(τ(x j ))) Among them, z i Represents the original image x i Embedding set, Loss assoc Represents the associated loss.

7. The impurity detection method based on semi-supervised learning according to claim 1, characterized in that: The calculation of the first sample set A i and the second sample set B j The associated loss and updating the weight parameters of the impurity detection model also include: According to the weight parameter (μ k , z j , z j ) is mapped to o k,i,j , where μ k represents the center of gravity variable, z i Represents the original image x i The embedding set z j Represents the enhanced image x j The embedding set of k,i,j represents cluster distribution; Converting the output of the impurity detection model into a probability distribution according to a softmax(x) function; Calculate the classification loss function Loss classification , and update the weight parameters.

8. The impurity detection method based on semi-supervised learning according to claim 1, characterized in that: According to the first sample set A i For the second sample set B j Make a prediction and use the most confident prediction result as the second sample set B j The pseudo labels also include: Define the enhanced loss function as: Loss trafo =|1-f(x i ) T f(τ(x j ))-crossentropy(o i ,o j )| Among them, crossentropy represents cross entropy, o i Represents the original image x i The logit value of j Represents the enhanced image x j The logit value of .

9. The impurity detection method based on semi-supervised learning according to claim 1, characterized in that: The first sample set A is obtained i and the second sample set B j Also includes: For the first sample set A i Perform data enhancement, specifically: Get the original image x i , where the original image x i For labeled data; From the original image x i Randomly crop a part of the area from the image, and then crop it out as the enhanced image x j ; and / or, randomly flip the original image x horizontally or vertically i , as the enhanced image x j ; And / or, to the original image x i Add Gaussian noise as the enhanced image x j ; And / or, for the original image x i Perform a small angle rotation as the enhanced image x j ; and / or, adjusting the original image x i The brightness, saturation and hue of the enhanced image x j ; Wherein, the enhanced image x j With the original image x i The labels are consistent.

10. A computer program product, characterized in that The invention comprises a computer program / instruction, which, when executed by a processor, implements the impurity detection method based on semi-supervised learning as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Defect detection system and mixed flaw training method

    CN118154494A

  • Deep learning-based anomaly detection in images

    US20230281959A1