A semi-supervised product surface defect detection method and system based on rebalancing

Through a semi-supervised method based on rebalancing, sample sampling and generative adversarial networks are used to solve the problems of small samples and imbalance in industrial scenarios, achieve efficient training of the judge and generator, and improve detection effect and computational efficiency.

CN114998258BActive Publication Date: 2025-09-19BEIJING UNIV OF POSTS & TELECOMM +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210617362.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-01
Publication Date
2025-09-19
Estimated Expiration
2042-06-01

AI Technical Summary

Technical Problem

In industrial scenarios, deep learning applications face problems of small samples and imbalance. Existing methods require multiple trainings, resulting in excessive model parameter coverage and computational overhead, and fail to fully exploit the correlation of sample imbalance.

Method used

A semi-supervised product surface defect detection method based on rebalancing is adopted. Through sample sampling generation, three-branch cumulative learning, average teacher consistency learning and generative adversarial network, a parameter update mechanism of the judge and generator is designed to achieve sample balance and improvement of computational efficiency.

Benefits of technology

It effectively solves the small sample and imbalance problems, avoids the update overlap of the decision parameter, saves computational overhead, and achieves sample balance and stability improvement through multi-task decoupling and generative adversarial methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114998258B_ABST
    Figure CN114998258B_ABST
Patent Text Reader

Abstract

The present application discloses a semi-supervised product surface defect detection method based on rebalancing and its system, wherein the semi-supervised product surface defect detection method based on rebalancing specifically includes the following steps: performing sample sampling, and obtaining generated samples based on the sampled samples; performing three-branch cumulative learning; performing average teacher consistency learning; performing decision parameter update; obtaining feature matching loss; performing label suppression, obtaining label suppression loss; performing generator parameter update; judging whether convergence is achieved; if converged, obtaining the product image to be detected, and performing preprocessing of the product image to be detected; inputting the processed image to be detected into the decision device to obtain the detection result; judging whether the currently obtained detection result is a real defect; if it is a real defect, outputting the obtained detection result. The method proposed in the present application can solve the common problems of small samples and imbalance in data sets in deep learning applications in industrial scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and specifically, to a semi-supervised product surface defect detection method and system based on rebalancing. Background Art

[0002] In industrial deep learning applications, datasets are often small and imbalanced. Research on small-sample datasets primarily focuses on fine-tuning methods, transfer learning, and semi-supervised learning. Model fine-tuning is a traditional approach to small-sample learning. It typically pre-trains the model on large-scale data and then fine-tunes the parameters of the fully connected layers or the top few layers of the neural network model on a target small-sample dataset to produce a fine-tuned model. Transfer learning leverages prior knowledge to learn new knowledge, aiming to quickly transfer previously learned knowledge to a new domain. Its effectiveness is influenced by the relationship between the source and target domains. Semi-supervised learning augments small-sample datasets with unlabeled data. Semi-supervised learning approaches, implemented from an adversarial perspective, combine the advantages of generative and discriminative clustering. Research on imbalanced datasets includes sampling, weighting, loss function design, transfer learning, and data generation. Sampling methods are simple but can lead to underfitting of the leading categories and overfitting of the trailing categories. Weighting methods can make model optimization more difficult in extremely imbalanced scenarios. Methods based on loss function design are difficult to design and offer limited performance improvements. Methods based on transfer learning are affected by the relationship between the source and target domains. Methods based on data generation can achieve good rebalancing results when the generator generates high-quality samples. For scenarios where both small sample sizes and imbalanced data are present, traditional methods typically employ a hierarchical training approach, training the model twice using semi-supervised and rebalancing methods. For example, separate methods are designed for the small sample size and imbalanced data, with multiple training runs, or a generative adversarial network model is first trained for data generation and then trained on a new dataset. These algorithmic design approaches have limitations. Sample imbalance is one of the contributing factors to the small sample size problem, but the two are not completely independent. Therefore, multiple training runs can cause model parameters obtained from the first training phase to be overwritten by model parameters from the later training phase, potentially invalidating the training of the first phase. Separate training fails to fully exploit the correlation between the two and results in additional computational overhead.

[0003] Therefore, how to propose a method to simultaneously solve the small sample and imbalance problems is an urgent problem that technicians in this field need to solve. Summary of the Invention

[0004] This paper aims to address the small sample size and imbalance issues commonly found in industrial scenarios by proposing a rebalancing-based semi-supervised product surface defect detection method. This method aims to simultaneously address both the small sample size and imbalance issues, leveraging the correlation between the two, avoiding the overwriting issue of model parameter updates after training, and reducing computational overhead.

[0005] In order to solve the above problems, the present application provides a semi-supervised product surface defect detection method based on rebalancing, which is characterized by comprising the following steps: S1, performing sample sampling and obtaining generated samples based on the sampled samples; S2, performing three-branch cumulative learning based on the sampled samples and the generated samples; S3, performing average teacher consistency learning based on the results of the three-branch cumulative learning; S4, performing decision parameter update based on the results of the three-branch cumulative learning and the average teacher consistency learning results; S5, performing feature matching based on the results of the three-branch cumulative learning and obtaining feature matching loss; S6, in response to Complete feature matching, perform label suppression, and obtain label suppression loss; S7, update the generator parameters according to the feature matching loss and label suppression loss; S8, determine whether convergence has been achieved; if not, repeat steps S2-S7; if converged, execute step S9; S9: obtain the product image to be inspected and preprocess the product image to be inspected; S10, input the processed image to be inspected into the judge to obtain the detection result; S11, determine whether the currently obtained detection result is a real defect; if it is a real defect, execute step S12; S12, output the obtained detection result.

[0006] As mentioned above, performing sample sampling and obtaining generated samples based on the sampled samples includes: performing sample sampling on the labeled data set and the unlabeled data set to obtain labeled samples and unlabeled samples; randomly sampling on the normally distributed noise, and inputting the sampling results into the generator to obtain generated samples.

[0007] As above, three-branch cumulative learning is performed according to the sampled samples and the generated samples. Three-branch cumulative learning is performed according to the sampled samples and the generated samples, specifically including the following sub-steps: decoupling the judge into a representation learning branch, a generation learning branch and a supervision learning branch; designing the training method of the representation learning branch, the generation learning branch and the supervision learning branch; in response to the completion of the training method design of the representation learning branch, the generation learning branch and the supervision learning branch, performing the structural design of the representation learning branch, the generation learning branch and the supervision learning branch; in response to the completion of the structural design of the representation learning branch, the generation learning branch and the supervision learning branch, performing three-branch cumulative learning.

[0008] As mentioned above, the design of the three-branch training method includes: obtaining the loss function of the representation learning branch trained on unlabeled samples; obtaining the loss function of the generation learning branch trained on generated samples; and obtaining the loss function of the supervised learning branch trained on labeled samples.

[0009] As above, where represents the loss function l of the learning branch trained on unlabeled samples rep Expressed as:

[0010]

[0011] Among them, x~p unl is an unlabeled sample, p(yx,D) is the probability that the unlabeled sample x is classified as label y by the decision machine D, Refers to finding the mean on unlabeled samples, represents minimizing the sample classification loss, Indicates that the sample estimation distribution needs to satisfy the category uniform distribution.

[0012] As above, the loss function l of the generative learning branch trained on the generated samples is gen Expressed as:

[0013]

[0014] Where E represents the mean value, and G(z) is the pseudo data generated by the random noise z input generator G. z [logp(y|G(z),D)] represents minimizing the sample classification loss, Indicates that the sample estimation distribution needs to satisfy the category uniform distribution.

[0015] As above, the loss function l of the supervised learning branch trained on the labeled samples is lab Expressed as:

[0016]

[0017] Where CE(·) represents the cross entropy function. lab Denotes a labeled sample. p(y|x,D) is the probability that the labeled sample x is classified as label y by the decision machine D.

[0018] As described above, based on the results of the three-branch cumulative learning, the average teacher consistency learning includes using the judge as the student model and updating the parameters of the average teacher model.

[0019] As above, the parameter update of the average teacher model is specifically expressed as:

[0020] W teacher (t) = β·W teacher(t-1)+(1-β)·W student

[0021] Where W teacher (t) represents the average teacher model parameters after the parameter update in this round, W student Represents the current student model parameters, W teacher (t-1) is the average teacher model parameters of the previous round of training.

[0022] A semi-supervised product surface defect detection system based on rebalancing specifically includes a sampling generation unit, a three-branch unit, a consistency learning unit, a judge parameter updating unit, a feature matching loss acquisition unit, a label suppression loss acquisition unit, a generator parameter updating unit, a first judgment unit, a preprocessing unit, a detection result acquisition unit, a second judgment unit and an output unit; the sampling generation unit is used to perform sample sampling and obtain generated samples based on the sampled samples; the three-branch unit is used to perform three-branch cumulative learning based on the sampled samples and the generated samples; the consistency learning unit is used to perform average teacher consistency learning based on the results of the three-branch cumulative learning; the judge parameter updating unit is used to perform judge parameter updating based on the results of the three-branch cumulative learning and the average teacher consistency learning results. New; a feature matching loss acquisition unit, used to perform feature matching according to the results of three-branch cumulative learning, and obtain feature matching loss; a label suppression loss acquisition unit, used to perform label suppression, and obtain label suppression loss; a generator parameter update unit, used to update the generator parameters according to the feature matching loss and label suppression loss; a first judgment unit, used to judge whether the generator and the judge have reached convergence; a preprocessing unit, used to obtain the product image to be detected and preprocess the product image to be detected if the generator and the judge have converged; a detection result acquisition unit, used to input the processed image to be detected into the judge to obtain the detection result; a second judgment unit, used to judge whether the currently obtained detection result is a real defect; an output unit, used to output the detection result if it is a real defect.

[0023] This application has the following beneficial effects:

[0024] The method proposed in this application can solve the common problems of small samples and imbalance in data sets in deep learning applications in industrial scenarios. The method of this application makes full use of the correlation between the two problems, avoids the update coverage problem after the discriminator parameters are trained, and saves computational overhead. The three-branch cumulative learning module designed in the discriminator of the method of this application eliminates the mutual interference of different tasks through multi-task decoupling, and realizes equivalent hierarchical training through cumulative learning; the designed average teacher model module improves the stability of the generative adversarial training process by calculating the average teacher consistency loss. The method of this application adopts a generative adversarial method in the generator to expand the sample data and achieve sample balance. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments recorded in this application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0026] Figure 1 1 is an internal structure diagram of a semi-supervised product surface defect detection system based on rebalancing provided in an embodiment of the present application;

[0027] Figure 2 This is a flow chart of a semi-supervised product surface defect detection method based on rebalancing provided in an embodiment of the present application. DETAILED DESCRIPTION

[0028] The following is a clear and complete description of the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.

[0029] The present invention proposes a semi-supervised product surface defect detection method and system based on rebalancing, which can solve the small sample and imbalance problems commonly existing in industrial scenarios, make full use of the correlation between the two problems, avoid the update coverage problem of the judgement parameters after training, and save computational overhead.

[0030] Example 1

[0031] like Figure 1 As shown, the semi-supervised product surface defect detection system based on rebalancing provided in this embodiment specifically includes: a sampling generation unit 110, a three-branch unit 120, a consistency learning unit 130, a judge parameter updating unit 140, a feature matching loss acquisition unit 150, a label suppression loss acquisition unit 160, a generator parameter updating unit 170, a first judgment unit 180, a preprocessing unit 190, a detection result acquisition unit 1100, a second judgment unit 1110, and an output unit 1120.

[0032] The sampling generation unit 110 is used to perform sample sampling and generate samples according to the sampled samples.

[0033] The three-branch unit 120 is connected to the sample generation unit 110 and is used to perform three-branch accumulation learning based on the sampled samples and the generated samples.

[0034] The consistency learning unit 130 is connected to the three-branch unit 120 and is used to perform average teacher consistency learning based on the results of the three-branch cumulative learning.

[0035] The decision parameter updating unit 140 is connected to the three-branch unit 120 and the consistency learning unit 130 respectively, and is used to update the decision parameter according to the results of the three-branch cumulative learning and the average teacher consistency learning result.

[0036] The feature matching loss acquisition unit 150 is connected to the three-branch unit 120 and is used to perform feature matching based on the results of the three-branch cumulative learning to obtain the feature matching loss.

[0037] The label suppression loss acquisition unit 160 is connected to the feature matching loss acquisition unit 150 and is used to perform label suppression and acquire the label suppression loss.

[0038] The generator parameter updating unit 170 is connected to the feature matching loss acquiring unit 150 and the label suppression loss acquiring unit 160 respectively, and is used to update the generator parameters according to the feature matching loss and the label suppression loss.

[0039] The first judgment unit 180 is connected to the generator parameter updating unit 170 and the decision parameter updating unit 140 respectively, and is used to judge whether the generator and the decision have reached convergence. If not, the above steps are repeated.

[0040] The preprocessing unit 190 is connected to the first judging unit 180 and is configured to obtain the product image to be detected and perform preprocessing on the product image to be detected if the generator and the judger converge.

[0041] The detection result acquisition unit 1100 is connected to the pre-processing unit 190 and is used to input the processed image to be detected into the decision device to obtain the detection result.

[0042] The second judgment unit 1110 is connected to the detection result acquisition unit 1100 and is used to judge whether the currently acquired detection result is a real defect. If it is not a real defect, the process exits.

[0043] The output unit 1120 is connected to the second judgment unit 1110 and is configured to output a detection result if the defect is a real defect.

[0044] Example 2

[0045] Scenario Assumption: Consider industrial scenarios with both small sample sizes and imbalanced data. A semi-supervised generative adversarial network is used to address the small sample size problem, while a rebalancing method based on generated data is used to address the imbalanced data problem.

[0046] like Figure 2As shown in FIG, a semi-supervised product surface defect detection method based on rebalancing provided by the present application includes the following steps:

[0047] Step S210: perform sample sampling and generate samples according to the sampled samples.

[0048] Specifically, labeled samples and unlabeled samples are obtained by sampling on the existing labeled dataset and unlabeled dataset respectively.

[0049] Preferably, the labeled dataset and the unlabeled dataset can be datasets that have been formed in the prior art.

[0050] And, randomly sample the normally distributed noise, and input the sampling results into the generator to obtain the generated samples.

[0051] The labeled dataset and the unlabeled dataset are obtained from the existing technology.

[0052] Step S220: Perform three-branch cumulative learning based on the sampled samples and the generated samples.

[0053] The unlabeled samples, generated samples and labeled samples are respectively input into the representation learning branch, rebalancing branch and supervised learning branch of the judge for training. Then, based on the preset cumulative learning curve, the output results of each branch are aggregated and the cumulative learning loss is calculated.

[0054] Specifically, this embodiment decouples the decision maker into a representation learning branch, a generation learning branch, and a supervised learning branch, which are trained on unlabeled samples, generated samples, and labeled samples, respectively.

[0055] Step S220 specifically includes the following sub-steps:

[0056] Step S2201: Design a three-branch training method.

[0057] where l represents the loss function l for training the learning branch on unlabeled samples. rep Expressed as:

[0058]

[0059] Among them, x~p unl is an unlabeled sample, p(yx,D) is the probability that the unlabeled sample x is classified as label y by the decision machine D, Refers to finding the mean on unlabeled samples, represents minimizing the sample classification loss, Indicates that the sample estimation distribution needs to satisfy the category uniform distribution.

[0060] The loss function l that the generative learning branch is trained on the generated samples is genExpressed as:

[0061]

[0062] Where E represents the mean value, and G(z) is the pseudo data generated by the random noise z input generator G. z [logp(y|G(z),D)] represents minimizing the sample classification loss, Indicates that the sample estimation distribution needs to satisfy the category uniform distribution.

[0063] The loss function l of the supervised learning branch trained on labeled samples lab Expressed as:

[0064]

[0065] Where CE(·) represents the cross entropy function. lab Denotes a labeled sample. p(y|x,D) is the probability that the labeled sample x is classified as label y by the decision machine D.

[0066] Step S2202: In response to completing the design of the three-branch training method, perform a three-branch structural design.

[0067] Specifically, in three-branch training, each branch is designed to have the same deep convolutional neural network architecture. This identical network structure indicates that the three branches are decoupled training of the same neural network model on different subtasks. Furthermore, each branch shares the representation layer weights.

[0068] Step S2203: In response to the completion of the three-branch structural design, three-branch cumulative learning is performed.

[0069] The output results of each branch are aggregated and the cumulative learning loss is calculated.

[0070] Specifically, on the output side of the three-branch unit, parallel cumulative learning based on weighted aggregation gradually shifts the training focus during training by changing the aggregation weights of each branch, achieving a "class-level" training effect. The weighted aggregation formula is expressed as:

[0071] f mix (x,z)=αD feat (x)+(1-α)D feat (G(z))

[0072] where f mix (x,z) represents the cumulative mixed feature map, D feat (x) represents the unlabeled sample feature map output by the learning branch, D feat (G(z)) represents the generated sample feature map output by the generative learning branch. α is the cumulative learning curve function, expressed as:

[0073]

[0074] Where t represents the sum of the training rounds of each branch, the current training round, and T represents the maximum number of training rounds that the three branches need to reach in advance.

[0075] Calculate the cumulative loss function l based on the cumulative mixed feature map cum , specifically expressed as:

[0076]

[0077] Where CE(·) represents the cross entropy function, x~p lab represents the label sample, p(y|x,D) is the probability that the label sample x is classified as label y by the judge D, where the cumulative mixed feature map is used as the intermediate layer output of the judge, p(y|f mix (x,z),D cls ) indicates that the output of the middle layer is mixed and then re-entered into the second half of the decision device D cls The decision result obtained by the decider is output.

[0078] Step S230: Perform average teacher consistency learning based on the results of the three-branch cumulative learning.

[0079] In this step, the decision maker in step S220 is used as the student model, T is set as the average teacher model, and the parameter update formula is:

[0080] W teacher (t) = β·W teacher (t-1)+(1-β)·W student

[0081] Where W teacher (t) and W student Represent the average teacher model parameters and current student model parameters after this round of parameter update, W teacher (t-1) is the average teacher model parameter of the previous round of training, and β is the weighting coefficient.

[0082] Calculate the mean square error between the student model and the average teacher model output to get the average teacher consistency learning loss l con , specifically expressed as:

[0083]

[0084] in is the output of the student model on unlabeled samples, It is the output of the historical average model on the same data. The consistency between the two outputs is improved by calculating the root mean square loss MSE(·).

[0085] Step S240: Update the decision parameter according to the three-branch cumulative learning results and the average teacher consistency learning result.

[0086] The parameters of the judge are updated according to the cumulative learning loss in step S220 and the average teacher consistency learning loss in step S230.

[0087] Specifically, the total loss function of the discriminator is obtained by weighted addition of the cumulative learning loss and the consistency learning loss, and the discriminator parameters are updated. The current round of discriminator training is completed.

[0088] The total loss function of the decision maker is l D Expressed as:

[0089]

[0090] where l cum is the cumulative learning loss of the three branches, l con Denotes the average teacher consistency learning loss as the average teacher consistency loss, is the weighting parameter.

[0091] Step S250: Perform feature matching based on the results of the three-branch cumulative learning to obtain the feature matching loss.

[0092] Specifically, feature matching is performed according to the generated learning feature graph and the represented learning feature graph in step S220.

[0093] Calculate the mean square error between the generated learning feature map and the representation learning feature map to get the feature matching loss l fm , expressed as:

[0094] l fm =MSE[D feat (G(z)),D feat (x|x~p unl )]

[0095] Among them D feat (G(z)) represents the generated sample feature map, D feat (x|x~p unl ) represents the unlabeled sample feature map.

[0096] Step S260: In response to completing feature matching, label suppression is performed to obtain label suppression loss.

[0097] The label sample labels are reverse sampled to obtain the suppressed labels, and the cross entropy of the generated sample judgment result and the suppressed labels is calculated to obtain the label suppression loss.

[0098] The label inverse sampling formula is:

[0099]

[0100] Among them, M′ k is the number of labels of the kth class after sampling, M k is the number of labels of the kth class before sampling, μ is the imbalance rate of the dataset, and K is the number of categories of each sample (where the number of categories of unlabeled samples, labeled samples, and generated samples is the same). The suppressed label y′ is generated based on the sampling results.

[0101] Calculate the cross entropy loss between the generated learning output and the suppressed label to get the label suppression loss l res , expressed as:

[0102] l res =CE z [y′,p(yG(z),D)]

[0103] Where CE(·) represents the cross entropy function, y′ represents the suppression label, and P(y=0|G(z),D) represents the probability that the generated sample G(z) is classified as a normal sample by the discriminator D.

[0104] Step S270: Update the generator parameters according to the feature matching loss and label suppression loss.

[0105] Specifically, the total loss function of the generator is obtained by weighted addition of the feature matching loss and the label suppression loss, the generator parameters are updated, and the generator training of the current round is completed.

[0106] The overall loss function of the generator is l G Expressed as:

[0107] l G =l res +λ·l fm

[0108] Among them, l res is the label suppression loss, l fm is the feature matching loss, and λ is the weighting coefficient.

[0109] Step S280: Determine whether convergence is achieved.

[0110] The determination of whether convergence is achieved is specifically to determine whether the accuracy of the judger and the generator has reached convergence, or whether the number of times the judger and the generator have been trained has reached a preset maximum number of training times.

[0111] If both the discriminator and the generator converge, the training of the discriminator and the generator is complete, and step S290 is executed. If not, steps S220-S270 are re-executed based on the updated discriminator parameters and generator parameters.

[0112] Step S290: Acquire the product image to be inspected and perform preprocessing on the product image to be inspected.

[0113] The preprocessing includes graphic transformation and cropping of the product image to be inspected.

[0114] Step S2100: input the processed image to be detected into the decision device to obtain the detection result.

[0115] The discriminator at this time is the discriminator trained in the above steps. Specifically, the processed image to be detected is input into the supervised learning branch of the discriminator to obtain the detection result of the image.

[0116] The detection results specifically include the defect type, number of defect types, and size of defect types in the product image.

[0117] The defect types include but are not limited to dead wrinkles, bubble sand, concave and convex spots, water spots, white spots, color difference wavy edges, jagged edges, insect marks, oxidation, perforation, and warping.

[0118] Step S2110: Determine whether the currently acquired detection result is a real defect.

[0119] The conditions for determining a true defect are to compare the number of defect types and the size of the defect types obtained with the preset alarm thresholds.

[0120] If the number of detected defect types is greater than the corresponding alarm threshold, and the defect type size is greater than the corresponding alarm threshold, the currently acquired detection result is a true defect, and step S2120 is executed. Otherwise, it is determined to be a non-defect and the process exits.

[0121] Step S2120: Output the acquired detection results.

[0122] This application has the following beneficial effects:

[0123] The method proposed in this application can solve the common problems of small samples and imbalance in data sets in deep learning applications in industrial scenarios. The method of this application makes full use of the correlation between the two problems, avoids the update coverage problem after the discriminator parameters are trained, and saves computational overhead. The three-branch cumulative learning module designed in the discriminator of the method of this application eliminates the mutual interference of different tasks through multi-task decoupling, and realizes equivalent hierarchical training through cumulative learning; the designed average teacher model module improves the stability of the generative adversarial training process by calculating the average teacher consistency loss. The method of this application adopts a generative adversarial method in the generator to expand the sample data and achieve sample balance.

[0124] Although the present application has been described with reference to examples, this is for illustrative purposes only and is not intended to limit the present application, and changes, additions and / or deletions to the embodiments may be made without departing from the scope of the present application.

[0125] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A semi-supervised product surface defect detection method based on rebalancing, characterized in that: The specific steps include: S1, sample sampling, and generate samples based on the sampled samples; S2, three-branch cumulative learning based on the sampled samples and generated samples; S3, based on the results of the three-branch cumulative learning, conducts average teacher consistency learning; S4, based on the cumulative learning results of the three branches and the average teacher consistency learning results, the decision parameter is updated; S5, perform feature matching based on the results of the three-branch cumulative learning to obtain the feature matching loss; S6, in response to completing feature matching, performing label suppression and obtaining label suppression loss; S7, update the generator parameters according to the feature matching loss and label suppression loss; S8, determine whether convergence is achieved; If it does not converge, repeat steps S2-S7; If converged, execute step S9; S9: Acquire an image of the product to be inspected and perform preprocessing on the image of the product to be inspected; S10, inputting the processed image to be detected into the decision device to obtain the detection result; S11, determining whether the currently obtained inspection result is a real defect; If it is a real defect, go to step S12; S12, output the obtained detection results; S2 performs three-branch cumulative learning based on the sampled samples and generated samples, including the following sub-steps: Decouple the discriminator into representation learning branch, generative learning branch, and supervised learning branch; train them on unlabeled samples, generated samples, and labeled samples respectively; Design training methods for representation learning branch, generative learning branch, and supervised learning branch; In response to completing the training method design of the representation learning branch, the generation learning branch, and the supervision learning branch, performing structural design of the representation learning branch, the generation learning branch, and the supervision learning branch; In response to completing the structural design of the representation learning branch, the generation learning branch, and the supervision learning branch, three-branch cumulative learning is performed.

2. The semi-supervised product surface defect detection method based on rebalancing according to claim 1, characterized in that: Perform sample sampling and generate samples based on the sampled samples, including: Perform sample sampling on the labeled dataset and the unlabeled dataset to obtain labeled samples and unlabeled samples; Randomly sample the normally distributed noise and input the sampling results into the generator to obtain the generated samples.

3. The semi-supervised product surface defect detection method based on rebalancing according to claim 1, characterized in that: The three-branch training method design includes: Get the loss function of the representation learning branch trained on unlabeled samples; Get the loss function of the generative learning branch trained on the generated samples; Get the loss function of the supervised learning branch trained on labeled samples.

4. The semi-supervised product surface defect detection method based on rebalancing according to claim 3, characterized in that: represents the loss function l of the learning branch trained on unlabeled samples rep Expressed as: Among them, x~p unl is an unlabeled sample, p(y|x,D) is the probability that the unlabeled sample x is classified as label y by the decision device D, Refers to finding the mean on unlabeled samples, represents minimizing the sample classification loss, Indicates that the sample estimation distribution needs to satisfy the category uniform distribution.

5. The semi-supervised product surface defect detection method based on rebalancing according to claim 3, characterized in that: The loss function l for the generative learning branch trained on generated samples gen Expressed as: Among them, E represents the mean, G(z) is the pseudo data generated by the random noise z input generator G, and E z [logp(y|G(z),D)] represents minimizing the sample classification loss, Indicates that the sample estimation distribution needs to satisfy the category uniform distribution.

6. The semi-supervised product surface defect detection method based on rebalancing according to claim 3, characterized in that: The loss function l of the supervised learning branch trained on labeled samples lab Expressed as: Among them, CE(·) represents the cross entropy function, x~p lab represents the label sample, and p(y|x,D) is the probability that the label sample x is classified as label y by the decision machine D.

7. The semi-supervised product surface defect detection method based on rebalancing according to claim 1, characterized in that: Based on the results of the three-branch cumulative learning, average teacher consistency learning is performed, which includes using the judge as the student model and updating the parameters of the average teacher model.

8. The semi-supervised product surface defect detection method based on rebalancing according to claim 1, characterized in that: The parameter update of the average teacher model is specifically expressed as: W teacher (t)=β·W teacher (t-1)+(1-β)·W student Where W teacher (t) represents the average teacher model parameters after the parameter update in this round, W student Represents the current student model parameters, W teacher (t-1) is the average teacher model parameters of the previous round of training.

9. A semi-supervised product surface defect detection system based on rebalancing, characterized in that: Specifically, it includes a sampling generation unit, a three-branch unit, a consistency learning unit, a decision parameter updating unit, a feature matching loss acquisition unit, a label suppression loss acquisition unit, a generator parameter updating unit, a first judgment unit, a preprocessing unit, a detection result acquisition unit, a second judgment unit and an output unit; A sampling generation unit, configured to perform sample sampling and generate samples based on the sampled samples; A three-branch unit, used for performing three-branch cumulative learning based on sampled samples and generated samples; The consistency learning unit is used to perform average teacher consistency learning based on the results of the three-branch cumulative learning; A discriminator parameter updating unit, configured to update the discriminator parameters according to the three-branch cumulative learning result and the average teacher consistency learning result; A feature matching loss acquisition unit is used to perform feature matching based on the results of the three-branch cumulative learning and obtain the feature matching loss; A label suppression loss acquisition unit, used for performing label suppression and acquiring label suppression loss; Generator parameter update unit, used to update the generator parameters according to feature matching loss and label suppression loss; A first judging unit, configured to judge whether the generator and the judge have reached convergence; A preprocessing unit, configured to obtain an image of a product to be detected and perform preprocessing on the image of the product to be detected if the generator and the judger converge; A detection result acquisition unit, used to input the processed image to be detected into the decision device to obtain the detection result; The second judging unit is used to judge whether the currently obtained detection result is a real defect; An output unit, used to output the detection result if it is a real defect; The three-branch unit performs three-branch cumulative learning based on the sampled samples and generated samples, including the following sub-steps: Decouple the discriminator into representation learning branch, generative learning branch, and supervised learning branch; train them on unlabeled samples, generated samples, and labeled samples respectively; Design training methods for representation learning branch, generative learning branch, and supervised learning branch; In response to completing the training method design of the representation learning branch, the generation learning branch, and the supervision learning branch, performing structural design of the representation learning branch, the generation learning branch, and the supervision learning branch; In response to completing the structural design of the representation learning branch, the generation learning branch, and the supervision learning branch, three-branch cumulative learning is performed.

Citation Information

Patent Citations

  • Pedestrian re-identification method fusing random batch masks and multi-scale representation learning

    CN111259850A

  • Autonomous and continuously self-improving learning system

    US11100373B1