Lens defect detection model training method, test method and readable storage medium

Through multi-channel heterogeneous anomaly distribution modeling and collaborative learning mechanism, the problems of data distribution heterogeneity and multi-channel information fusion in lens defect detection are solved, and lens defect detection with high precision and high generalization capabilities are achieved.

CN120235855AInactive Publication Date: 2025-07-01HANGZHOU HUICUI INTELLIGENT TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510694070.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-28
Publication Date
2025-07-01
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing lens defect detection methods fail to fully consider the heterogeneity of data distribution, it is difficult to fully capture the lens diversity defects, and the detection accuracy and generalization capabilities are insufficient in the case of multi-channel information fusion and scarcity of abnormal samples.

Method used

Multi-channel heterogeneous anomaly distribution modeling and collaborative learning mechanism are adopted to pre-process by reading multi-channel image data, dynamically adjust the sub-model weight, and weighted aggregation calculation to build a lens defect detection model.

Benefits of technology

It significantly improves the accuracy and generalization performance of lens defect detection, can more accurately identify unseen abnormal samples, and has good cross-domain detection capabilities and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120235855A_ABST
    Figure CN120235855A_ABST
Patent Text Reader

Abstract

The invention discloses a lens defect detection model training method, a test method and a readable storage medium. The training method comprises the following steps: reading multi-channel image data, and preprocessing to obtain sample data of different channels; performing data processing based on the sample data to obtain a training data set, wherein the training data set comprises a normal data set and an abnormal data set; training a plurality of preset lens defect detection sub-models by using the training data set, wherein the training process also comprises the step of dynamically adjusting the weights of the sub-models; and performing weighted aggregation calculation based on an output result of each sub-model to obtain an abnormal score, and outputting a defect detection result of the current sample data based on the abnormal score. According to the method, complex heterogeneous abnormal distribution can be simulated by utilizing multi-channel information, the precision and generalization performance of lens defect detection are remarkably improved through multi-channel heterogeneous abnormal distribution modeling and a collaborative learning mechanism, the limitation of a traditional method is overcome, and the method is particularly suitable for lens defect detection and other high-precision detection scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of device detection, and more specifically, to a method for training a lens defect detection model, a testing method, and a readable storage medium. Background Art

[0002] Anomaly detection (AD) has important applications in the industrial field, especially in product quality control, equipment fault diagnosis, and production process monitoring. With the development of industrial automation and intelligence, higher requirements are put forward for the accuracy and efficiency of anomaly detection. Among them, lens defect detection is an important branch of industrial defect detection, and the goal is to identify various defects generated in the lens manufacturing process to ensure product quality.

[0003] Currently, the following technical problems exist in lens defect detection: (1) The problem of data distribution heterogeneity. Among them, traditional methods assume that the data distribution is homogeneous and do not fully consider the different data distribution characteristics corresponding to different types of defects; (2) The problem of multi-channel information fusion. Among them, most existing methods rely on single-channel image data and it is difficult to comprehensively capture the diverse defects of the lens; (3) The problem of scarce abnormal samples. Among them, in actual industrial production, it is difficult to obtain a large number of abnormal samples. Summary of the Invention

[0004] The purpose of the present invention is to provide a method for training a lens defect detection model, a testing method, and a readable storage medium, which are applied to defect detection in the lens manufacturing process, especially for the technical problems of lens defect detection for multi-channel images.

[0005] The first aspect of the present invention provides a method for training a lens defect detection model, including the following steps: Read multi-channel image data and perform preprocessing to obtain sample data of different channels; Based on the sample data, perform data processing to obtain a training data set, where the training data set includes a normal data set and an abnormal data set; Use the training data set to train a plurality of preset lens defect detection sub-models, and during the training process, the weights of the sub-models are also dynamically adjusted; Based on the output results of each sub-model, perform weighted aggregation calculation to obtain an anomaly score, and based on the anomaly score, output the defect detection result of the current sample data.

[0006] In this solution, the step of reading multi-channel image data and performing preprocessing to obtain sample data of different channels specifically includes: The multi-channel includes a first channel, a second channel, a third channel, a fourth channel, and a fifth channel. Among them, The first channel includes a coaxial light grayscale image for detecting standard defects; The second channel includes a laser projection image for detecting lens forming defects; The third channel includes a multi-level laser color image for detecting micro glass structure defects; The fourth channel includes a coaxial light blue image for detecting fine defects; The fifth channel includes a laser grayscale image for detecting edge chipping and burr defects; Read the image data of the multi-channel and perform preprocessing to obtain the sample data. Among them, the preprocessing methods include denoising and normalization processing.

[0007] In this solution, performing data processing based on the sample data to obtain a training dataset specifically includes: Performing clustering on the normal samples in the sample data and dividing them into multiple clusters to simulate a heterogeneous normal distribution to obtain a normal dataset; Performing random sampling on the abnormal samples in the sample data and combining with a pseudo-abnormal sample generation algorithm to construct an abnormal dataset; Obtaining the training dataset based on the normal dataset and the abnormal dataset.

[0008] In this solution, training a preset multiple lens defect detection sub-models using the training dataset, and during the training process, dynamically adjusting the weights of the sub-models specifically includes: Training multiple lens defect detection sub-models using the training dataset. Among them, each sub-model is optimized using a preset loss function. The loss function includes a classification loss that measures the classification accuracy of the model for abnormal samples and normal samples and a regularization term to prevent the model from overfitting, and stop the iterative training until the loss function is minimized; Dynamically adjusting the weights of each sub-model based on the training dataset. Among them, calculate the loss value of each sub-model during training to obtain a performance parameter, and use a time series model to model the performance parameter of the sub-model to dynamically adjust the weights.

[0009] In this solution, performing weighted aggregation calculation based on the output results of each sub-model to obtain an anomaly score, and outputting the defect detection result of the current sample data based on the anomaly score specifically includes: Performing weighted aggregation calculation by multiplying the output result of each sub-model with the corresponding weight to obtain the anomaly score; Performing threshold judgment based on the anomaly score to output whether the current sample data is a defect anomaly, and outputting the judgment result as the defect detection result.

[0010] In a second aspect of the present invention, there is provided a method for testing a lens defect detection model, which is applied to the lens defect detection model obtained by any one of the lens defect detection model training methods. The method includes the following steps: Obtain test data; Input the test data into the lens defect detection model to obtain a model result; Output externally based on the model result.

[0011] In a third aspect of the present invention, there is also provided a lens defect detection model training system, including a memory and a processor. The memory includes a program for the lens defect detection model training method. When the program for the lens defect detection model training method is executed by the processor, the following steps are implemented: Read multi-channel image data and perform preprocessing to obtain sample data of different channels; Perform data processing based on the sample data to obtain a training data set, where the training data set includes a normal data set and an abnormal data set; Use the training data set to train a plurality of preset lens defect detection sub-models, and during the training process, the weights of the sub-models are also dynamically adjusted; Perform weighted aggregation calculation based on the output results of each sub-model to obtain an abnormal score, and output the defect detection result of the current sample data based on the abnormal score.

[0012] In this solution, the step of reading multi-channel image data and performing preprocessing to obtain sample data of different channels specifically includes: The multi-channels include a first channel, a second channel, a third channel, a fourth channel, and a fifth channel, where The first channel includes a coaxial light grayscale image for detecting standard defects; The second channel includes a laser projection image for detecting lens molding defects; The third channel includes a multi-level laser color image for detecting micro glass structure defects; The fourth channel includes a coaxial light blue image for detecting fine defects; The fifth channel includes a laser grayscale image for detecting edge chipping and burr defects; Read the multi-channel image data and perform preprocessing to obtain the sample data, where the preprocessing methods include denoising and normalization processing.

[0013] In this solution, the step of performing data processing based on the sample data to obtain a training data set specifically includes: Cluster the normal samples in the sample data into multiple clusters to simulate a heterogeneous normal distribution and obtain a normal data set; Randomly sample the abnormal samples in the sample data and combine them with a pseudo-abnormal sample generation algorithm to construct an abnormal data set; Obtain the training data set based on the normal data set and the abnormal data set.

[0014] In this solution, when using the training data set to train a preset number of lens defect detection sub-models, the training process also includes dynamically adjusting the weights of the sub-models, specifically including: Use the training data set to train multiple lens defect detection sub-models. Among them, each sub-model is optimized using a preset loss function. The loss function includes a classification loss that measures the classification accuracy of the model for abnormal samples and normal samples, and a regularization term to prevent the model from overfitting. Stop iterative training until the loss function is minimized; Dynamically adjust the weights of each sub-model based on the training data set. Among them, calculate the loss value of each sub-model during training to obtain a performance parameter, and use a time series model to model the performance parameter of the sub-model to dynamically adjust the weights.

[0015] In this solution, weighted aggregation calculation is performed based on the output results of each sub-model to obtain an abnormal score, and the defect detection result of the current sample data is output based on the abnormal score. Specifically including: Perform weighted aggregation calculation by multiplying the output result of each sub-model by the corresponding weight to obtain the abnormal score; Perform threshold judgment based on the abnormal score to output whether the current sample data is a defect anomaly, and output the judgment result as the defect detection result.

[0016] The fourth aspect of the present invention also provides a lens defect detection model testing system, including a memory and a processor. The memory includes a lens defect detection model testing method program. When the lens defect detection model testing method program is executed by the processor, the following steps are implemented: Obtain test data; Input the test data into the lens defect detection model to obtain a model result; Output externally based on the model result.

[0017] The fifth aspect of the present invention provides a computer-readable storage medium. The computer-readable storage medium includes a lens defect detection model training method program for a machine. When the lens defect detection model training method program is executed by a processor, the steps of a lens defect detection model training method as described in any one of the above and / or the steps of a lens defect detection model testing method as described above are implemented.

[0018] A method for training a lens defect detection model, a testing method, and a readable storage medium disclosed by the present invention significantly improve the accuracy and generalization performance of lens defect detection through multi-channel heterogeneous anomaly distribution modeling and a collaborative learning mechanism, overcome the limitations of traditional methods, and are particularly suitable for lens defect detection and other scenarios requiring high-precision detection. The specific beneficial effects are as follows: (1) Strong heterogeneous anomaly modeling ability. Specifically, the present invention makes full use of multi-channel information, can simulate complex heterogeneous anomaly distributions, and improves the detection performance of the model for unseen anomalies; (2) Enhanced open-set detection ability. Specifically, through heterogeneous modeling and a collaborative learning mechanism, the present invention can effectively handle open-set anomaly detection tasks; (3) Dynamic optimization mechanism. Specifically, based on a weight adjustment strategy of historical training information, the weights of each sub-model are dynamically optimized, improving the stability and robustness of the model; (4) Cross-channel generalization ability. Specifically, the present invention makes full use of the information of each channel to achieve comprehensive defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 Shows a flowchart of a method for training a lens defect detection model of the present invention; Figure 2 Shows a flowchart of a method for testing a lens defect detection model of the present invention; Figure 3 Shows a block diagram of a system for training a lens defect detection model of the present invention; Figure 4 Shows a block diagram of a system for testing a lens defect detection model of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0020] In order to more clearly understand the above objects, features, and advantages of the present invention, the present invention will be further described in detail below with reference to the drawings and specific embodiments. It should be noted that, without conflict, the embodiments of the present application and the features in the embodiments can be combined with each other.

[0021] In the following description, many specific details are set forth in order to fully understand the present invention. However, the present invention can also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited by the specific embodiments disclosed below.

[0022] Abnormality detection (AD) has important application value in the industrial field and is widely used in product quality control, equipment fault diagnosis, production process monitoring, etc. With the development of industrial automation and intelligence, higher requirements are put forward for the accuracy and efficiency of abnormality detection. However, when dealing with abnormality detection tasks in complex industrial scenarios, existing technologies face challenges such as data distribution heterogeneity, difficulty in multi-channel information fusion, and scarcity of abnormal samples, making it difficult to meet the needs of practical applications. For example, in the lens manufacturing process, due to complex processes and diverse defect types, traditional abnormality detection methods are difficult to accurately identify various subtle defects, resulting in insufficient product quality guarantee, affecting the production efficiency and market competitiveness of enterprises. The purpose of abnormality detection is to identify data points that deviate from the overall sample. Most methods regard abnormality detection as a homogeneous distribution detection, that is, there are only normal distributions and abnormal distributions. There is an unreasonable aspect in doing so, which is that the heterogeneity existing in the data distribution itself is not considered. Open Set Supervised Anomaly Detection (OSAD) is an emerging field of abnormality detection, aiming to detect unseen anomalies (i.e., samples from open set anomaly classes) by using a small number of abnormal class samples observed during the training process, while effectively identifying seen anomalies. With the prior knowledge reflected by seen anomalies, current OSAD methods can usually significantly reduce false positive errors. However, these methods are trained in a closed set environment and regard abnormal samples as coming from a homogeneous distribution, which makes them perform poorly when generalizing to unseen anomalies of any distribution.

[0023] To solve this problem, this application proposes a method for learning heterogeneous anomaly distributions using limited anomaly samples. For this purpose, a novel method, namely Anomalous Heterogeneity Learning (AHL), is introduced. This method simulates a diverse set of heterogeneous anomaly distributions and uses them to learn a unified heterogeneous anomaly model in an alternative open-set environment. In addition, AHL is a general framework, and existing OSAD models can be easily incorporated to enhance their anomaly modeling capabilities. Lens defect detection is an important branch of industrial defect detection. Existing defect detection technologies have the following limitations: (1) Unreasonable assumption of data distribution. Most existing methods regard anomaly detection as homogeneous distribution detection, assuming that data only has normal and abnormal distributions. However, actual data often has heterogeneity, and different types of defects correspond to different data distribution characteristics. For example, images of certain channels are suitable for detecting surface defects, while other channels are more suitable for detecting internal structure anomalies. Traditional methods fail to fully consider the heterogeneity of data distribution, resulting in limited detection accuracy; (2) Insufficient utilization of multi-channel information. Most existing technologies rely on image data of a single channel for defect detection, making it difficult to comprehensively capture the diverse defects of the lens. Image data of different channels contains rich complementary information, but traditional methods fail to effectively fuse multi-channel information and cannot fully utilize its potential advantages, affecting the detection performance; (3) Limitations in handling anomaly samples. In actual industrial production, it is difficult to obtain a large number of anomaly samples, while existing methods often require a large number of anomaly samples for training. In addition, some methods regard anomaly samples as coming from a homogeneous distribution during training, which limits the generalization ability of the model when facing unseen anomaly types and is prone to false positive errors.

[0024] Suppose the training set is {X, Y}, where X_i represents an RGB image with label Y_i. Y_i = 1 represents an anomaly, otherwise it represents normal. For a given AD model f(X; θ), let z_i be the feature of the i-th image under the AD model. To better distinguish between abnormal data and normal data, z_normal and z_abnormal are used to represent the features of normal data and abnormal data respectively. Since only a small part of the abnormal data can be seen by the model during the training process, the set of categories C_abnormal to which z_abnormal belongs is only a subset of C_all, where C_all is the set of all possible anomaly categories.

[0025] The task of AHL is to model a mapping A(X; θ) so that higher scores can be assigned to anomalous images sampled from different distributions. Among them, the core idea of the AHL framework is to learn a unified heterogeneous anomaly model in the simulated anomaly distribution, which consists of two parts. Specifically, the Heterogeneous Anomaly Distribution Generation (HADG) and the Collaborative Differentiable Learning of the anomaly heterogeneity (CDL). HADG is responsible for generating K heterogeneous distribution datasets D_k from the training set, where D_k contains the normal dataset and the data randomly sampled from the anomalous data, and each D_k can be generated from the perspective of ensuring representation of a different distribution from others; while CDL is used to construct the above-mentioned A(X; θ), that is, f(X; θ). The unified heterogeneous anomaly detection model can be regarded as the synthesis of K sub-models, f(X; θ)=Σα_kf_k(X; θ_k), and each sub-model f_k learns the anomalous data in the anomaly distribution represented by D_k. Among them, θ and {θ_k} represent the parameters of the unified model and the K sub-models respectively, and α_k is collaboratively updated based on {θ_k}. Since the performance differences of different sub-models may be very large, a module is added in CDL to increase the weight of α_k in the collaborative update. If the generalization error of this sub-model is small (because the loss value is relatively small), through a certain regularization method, the weight adjustment is made more reasonable. Correspondingly, only the unified model f(X; θ) is used for inference.

[0026] HADG is used to generate K sub-datasets D_k of heterogeneous anomaly distributions, where D_k = {D_k^normal, D_k^abnormal}, and the sampling schemes for D_k^normal and D_k^abnormal for normal and anomalous data need to be discussed separately.

[0027] Specifically, for the normal data D_k^normal: In order to make it represent the main distribution of the normal data and the normal samples of different sub-datasets are not exactly the same, HADG uses k-means clustering to divide D_k into C clusters, and then samples D_k^normal from one of these C clusters. During the clustering process, the division is made according to the feature similarity of the data to ensure the differences between different clusters.

[0028] The abnormal data D_k^abnormal: To ensure the diversity of abnormal samples, D_k^abnormal is sampled from two parts: one is directly randomly sampled from D_abnormal; the other is the pseudo-abnormal sample generation algorithm: by methods such as data augmentation and noise injection, samples similar to but with certain differences from real abnormal samples are generated to increase the diversity of abnormal data.

[0029] CDL is used to construct sub-models f_k for the K sub-samples generated by HADG and aggregate the K sub-models into the final anomaly detection model f. First, the sub-model is optimized: for the sub-model f_k, θ_k is optimized and updated through the following loss function: L(f_k) = Σ [L_CE(f_k(X), Y) + λ||f_k(X) - μ||^2 / σ^2] Among them, L(f_k) is the loss function of the sub-model f_k, μ and σ are the variance and mean of the overall population estimated from the samples, L_CE is the classification loss, which is used to measure the classification accuracy of the model for abnormal and normal samples, and the regularization term λ is used to prevent the model from overfitting.

[0030] After updating θ_k, calculate the losses of all sub-models on the query set and update α_k: α_k = softmax(-E(f_k)). Finally, importance scores learning is carried out. Specifically, to solve problems such as unstable updates caused by overly large performance differences among different sub-models. Among them, the present invention proposes an importance scores based on historical training information to correct α_k: The importance scores are modeled as a time series model with respect to the epoch; The final weight is the softmax of the negative generalization error of α_k. Substitute the compensation weight into f(X; θ) to complete the update of the aggregated detector, and the training phase ends.

[0031] In view of the above problems, the present application proposes a detection method based on heterogeneous anomaly distribution modeling, which uses multi-channel information for joint modeling. Specifically, this method first extracts features from the data of each channel by jointly modeling the information of different channels, and then uses an attention mechanism to fuse the multi-channel features to ensure the complementarity of heterogeneous information. In addition, this method also uses a weighted aggregation strategy to weight the features from different channels according to the importance distribution, thereby improving the overall detection effect and overcoming the deficiencies of traditional methods. Further, it should be noted that the present invention believes that it is very easy to obtain abnormal samples in industrial practice. Therefore, the focus of the present invention is how to overcome the wrong assumption that the data distribution is uniform in conventional anomaly detection algorithms in the case of a small number of abnormal samples, so as to improve the performance. The discussion scope of the present invention is: during training, the input data is mixed with a small number of abnormal samples, and during testing, there will be abnormal samples that have never appeared and abnormal samples that have appeared.

[0032] Figure 1 The flowchart of a method for training a lens defect detection model according to the present application is shown.

[0033] As Figure 1 shown, the present application discloses a method for training a lens defect detection model, including the following steps: S102, read multi-channel image data and perform preprocessing to obtain sample data of different channels; S104, perform data processing on the sample data to obtain a training data set, wherein the training data set includes a normal data set and an abnormal data set; S106, use the training data set to train a plurality of preset lens defect detection sub-models, and during the training process, the weights of the sub-models are also dynamically adjusted; S108, perform weighted aggregation calculation based on the output results of each sub-model to obtain an anomaly score, and output the defect detection result of the current sample data based on the anomaly score.

[0034] It should be noted that in this embodiment, first read multi-channel image data and perform preprocessing to obtain sample data of different channels. Among them, the multi-channel includes a first channel, a second channel, a third channel, a fourth channel, and a fifth channel, so as to read the image data corresponding to the five channels and perform preprocessing to obtain sample data. Then, perform normal sample clustering and heterogeneous normal distribution simulation to obtain a normal data set, and perform heterogeneous abnormal data generation to obtain an abnormal data set. Furthermore, obtain a training data set based on the normal data set and the abnormal data set.

[0035] Furthermore, use the training data set to train a plurality of preset lens defect detection sub-models. Each sub-model focuses on learning a specific abnormal distribution. By optimizing the loss function, the sub-model can accurately identify abnormal samples in the sub-data set. The training process also includes dynamically adjusting the weights of the sub-models. The weight adjustment strategy considers the performance of the sub-models in the historical training process, preferentially increasing the weights of the sub-models with better performance, and at the same time giving a certain adjustment space to the sub-models with poor performance to ensure the stability and robustness of model fusion; finally, perform weighted aggregation calculation based on the output results of each sub-model to obtain an abnormal score, and output the defect detection result of the current sample data based on the abnormal score.

[0036] According to the embodiment of the present invention, the reading of multi-channel image data and preprocessing to obtain sample data of different channels specifically includes: The multi-channels include a first channel, a second channel, a third channel, a fourth channel, and a fifth channel, where The first channel includes a coaxial light gray-scale image for detecting standard defects; The second channel includes a laser projection image for detecting lens molding defects; The third channel includes a multi-level laser color image for detecting micro glass structure defects; The fourth channel includes a coaxial light blue image for detecting fine defects; The fifth channel includes a laser gray-scale image for detecting edge chipping and burr defects; Read multi-channel image data and perform preprocessing to obtain the sample data, where the preprocessing methods include denoising and normalization processing.

[0037] It should be noted that in this embodiment, the multiple channels read include the first channel, the second channel, the third channel, the fourth channel, and the fifth channel. Among them, each channel is used to transmit image data. Therefore, the input images corresponding to each channel are read for preprocessing. Among them, the first channel includes a coaxial light grayscale image for detecting standard defects, where the standard defects correspond to obvious defects, such as inconsistent grayscale images; the second channel includes a laser projection image for detecting lens molding defects; the third channel includes a multi-level laser color image for detecting glass structure defects; the fourth channel includes a coaxial light blue image for detecting detail defects; the fifth channel includes a laser grayscale image for detecting edge chipping defects and burr defects. Furthermore, the image data of multiple channels are read for preprocessing to obtain the sample data. Among them, image data are read from five different channels (coaxial light grayscale image, laser projection image, multi-level laser color image, coaxial light blue image, laser grayscale image), and the image data of each channel represent different detection tasks (such as surface defects, internal structure abnormalities, etc.). Automatic preprocessing is performed on the images of each channel, including using a filtering algorithm (such as Gaussian filtering) to remove image noise and normalizing the image pixel values to a fixed range (such as [0,1]) for subsequent feature extraction. The preprocessed image data are stored in a unified format for use by subsequent modules. Through denoising processing and normalization processing, the data quality can be ensured, and the interference of noise on subsequent feature extraction can be reduced.

[0038] According to an embodiment of the present invention, the training data set is obtained by performing data processing based on the sample data, specifically including: The normal samples in the sample data are clustered into multiple clusters to simulate a heterogeneous normal distribution to obtain a normal data set; Random sampling is performed on the abnormal samples in the sample data and combined with a pseudo-abnormal sample generation algorithm to construct an abnormal data set; The training data set is obtained based on the normal data set and the abnormal data set.

[0039] It should be noted that in this embodiment, the k-means clustering algorithm is used to automatically cluster the normal samples. Among them, the normal samples in the sample data are divided into multiple clusters, and each cluster represents a sub-distribution of normal data. During the clustering process, the division is performed according to the feature similarity of the data to ensure the difference between different clusters. Correspondingly, the clustering result is used to simulate the heterogeneous distribution of normal data.

[0040] Further, randomly sample from the abnormal data in the sample data, and combine with the pseudo-abnormal sample generation algorithm to automatically construct multiple heterogeneous abnormal sub-datasets. Among them, through methods such as data augmentation (such as rotation, scaling) and noise injection (such as Gaussian noise), generate samples that are similar to the real abnormal samples but have certain differences. Each sub-dataset contains normal samples and abnormal samples to ensure the diversity of abnormal data.

[0041] According to the embodiment of the present invention, when training a plurality of preset lens defect detection sub-models using the training dataset, the training process further includes dynamically adjusting the weights of the sub-models, specifically including: Train a plurality of lens defect detection sub-models using the training dataset. Among them, each sub-model is optimized using a preset loss function. The loss function includes a classification loss that measures the classification accuracy of the model for abnormal samples and normal samples and a regularization term that prevents the model from overfitting. Stop iterative training until the loss function is minimized. Dynamically adjust the weights of each sub-model based on the training dataset. Among them, calculate the loss value of each sub-model during training to obtain a performance parameter, and use a time series model to model the performance parameter of the sub-model to dynamically adjust the weights.

[0042] It should be noted that in this embodiment, a plurality of lens defect detection sub-models are trained using the training dataset. Among them, each sub-model focuses on learning a specific abnormal distribution and is optimized using a loss function. Correspondingly, the loss function includes a classification loss that measures the classification accuracy of the model for abnormal samples and normal samples and a regularization term that prevents the model from overfitting. During the training process, adjust the model parameters until the loss function is minimized and stop iterative training.

[0043] Further, dynamically adjust the weights of each sub-model based on the training dataset and combine historical data for training, thereby dynamically adjusting the weights of each sub-model. Among them, calculate the performance performance (such as loss value) of each sub-model in historical training, preferentially increase the weights of the sub-models with better performance, and at the same time give a certain adjustment space to the sub-models with poor performance. Finally, use the Softmax function to normalize the weights to ensure the rationality of weight adjustment.

[0044] According to the embodiment of the present invention, weighted aggregation calculation is performed based on the output results of each sub-model to obtain an abnormal score, and a defect detection result of the current sample data is output based on the abnormal score, specifically including: Perform weighted aggregation calculation by multiplying the output result of each sub-model by the corresponding weight to obtain the abnormal score; Perform threshold judgment based on the abnormal score to output whether the current sample data is a defective abnormality, and output the judgment result as the defect detection result.

[0045] It should be noted that in this embodiment, the output results of multiple sub-models are weighted and aggregated. Among them, the output result of each sub-model is multiplied by its corresponding weight for weighted aggregation, and then the anomaly score is calculated. Furthermore, a threshold judgment is performed based on the anomaly score to output whether the current sample data is a defect anomaly, and the judgment result is output as the defect detection result.

[0046] Figure 2 The flowchart of a method for testing a lens defect detection model according to the present application is shown.

[0047] As Figure 2 shown, the present application discloses a method for testing a lens defect detection model, which is applied to the lens defect detection model obtained by any one of the above-mentioned lens defect detection model training methods. Among them, the method includes the following steps: S202, obtaining test data; S204, inputting the test data into the lens defect detection model to obtain a model result; S206, outputting externally based on the model result.

[0048] It should be noted that in this embodiment, the content of testing using the lens defect detection model is described. Among them, first, test data is obtained, then the test data is input into the lens defect detection model to obtain a model result, and finally, an external output is made based on the model result.

[0049] Specifically, in the embodiment of lens defect detection, the lens defect detection model in this embodiment is tested on a lens defect detection data set with five channels. The experimental results show that the method in this embodiment is superior to the existing mainstream methods in terms of the AUROC (Area Under the Receiver Operating Characteristic curve) index. The specific data is as follows: the AUROC index of the method in this embodiment is "0.92", while the AUROC index of the existing mainstream methods is "0.77". For unseen anomaly types, the accuracy of the method of the present invention is "88%", and the accuracy of the existing mainstream methods is "55%". This result proves the effectiveness and superiority of the method in the task of detecting lens defects, can more accurately identify abnormal samples, and has high practical application value.

[0050] Specifically, in the embodiments of cross-domain testing, for the test data sets of different lens types, the lens defect detection model in this embodiment performs excellently in cross-domain detection tasks. The specific data is as follows: In cross-domain testing, the accuracy rate of the model in this embodiment reaches "91%", proving its good generalization ability. Correspondingly, compared with other methods, the accuracy rate in cross-domain testing is only "78%", and the model of the present invention has obvious advantages.

[0051] Figure 3 The block diagram of a lens defect detection model training system of the present invention is shown.

[0052] As Figure 3 shown, the present invention discloses a lens defect detection model training system, including a memory and a processor. The memory includes a lens defect detection model training method program. When the lens defect detection model training method program is executed by the processor, the following steps are implemented: Read multi-channel image data and perform preprocessing to obtain sample data of different channels; Based on the sample data, perform data processing to obtain a training data set, where the training data set includes a normal data set and an abnormal data set; Use the training data set to train a plurality of preset lens defect detection sub-models, and during the training process, the weights of the sub-models are also dynamically adjusted; Based on the output results of each sub-model, perform weighted aggregation calculation to obtain an abnormal score, and based on the abnormal score, output the defect detection result of the current sample data.

[0053] It should be noted that in this embodiment, first, multi-channel image data is read and preprocessed to obtain sample data of different channels. Among them, the multi-channel includes the first channel, the second channel, the third channel, the fourth channel, and the fifth channel. Thus, the image data corresponding to the five channels is read and preprocessed to obtain sample data. Then, normal sample clustering and heterogeneous normal distribution simulation are performed to obtain a normal data set, and heterogeneous abnormal data generation is performed to obtain an abnormal data set. Furthermore, a training data set is obtained based on the normal data set and the abnormal data set.

[0054] Furthermore, use the training data set to train a plurality of preset lens defect detection sub-models. Each sub-model focuses on learning a specific abnormal distribution. By optimizing the loss function, the sub-model can accurately identify abnormal samples in the sub-data set. The training process also includes dynamically adjusting the weights of the sub-models. The weight adjustment strategy considers the performance of the sub-models in the historical training process, preferentially increasing the weights of the sub-models with better performance, and at the same time giving a certain adjustment space to the sub-models with poor performance to ensure the stability and robustness of model fusion. Finally, weighted aggregation calculation is performed based on the output results of each sub-model to obtain an abnormal score, and the defect detection result of the current sample data is output based on the abnormal score.

[0055] According to an embodiment of the present invention, the reading of multi-channel image data and preprocessing to obtain sample data of different channels specifically includes: The multi-channels include a first channel, a second channel, a third channel, a fourth channel, and a fifth channel, where The first channel includes a coaxial light grayscale image for detecting standard defects; The second channel includes a laser projection image for detecting lens molding defects; The third channel includes a multi-level laser color image for detecting micro glass structure defects; The fourth channel includes a coaxial light blue image for detecting fine defects; The fifth channel includes a laser grayscale image for detecting edge chipping and burr defects; Read multi-channel image data and perform preprocessing to obtain the sample data, where the preprocessing methods include denoising and normalization processing.

[0056] It should be noted that in this embodiment, the multiple channels read include the first channel, the second channel, the third channel, the fourth channel, and the fifth channel. Each channel is used to transmit image data. Therefore, the input images corresponding to each channel are read for preprocessing. Among them, the first channel includes a coaxial light grayscale image for detecting standard defects, where the standard defects correspond to obvious defects, such as inconsistent grayscale images; the second channel includes a laser projection image for detecting lens molding defects; the third channel includes a multi-level laser color image for detecting glass structure defects; the fourth channel includes a coaxial light blue image for detecting detail defects; the fifth channel includes a laser grayscale image for detecting edge chipping defects and burr defects. Then, the image data of multiple channels are read for preprocessing to obtain the sample data. Among them, image data are read from five different channels (coaxial light grayscale image, laser projection image, multi-level laser color image, coaxial light blue image, laser grayscale image), and the image data of each channel represent different detection tasks (such as surface defects, internal structure abnormalities, etc.). Automatic preprocessing is performed on the images of each channel, including using a filtering algorithm (such as Gaussian filtering) to remove image noise and normalizing the image pixel values to a fixed range (such as [0,1]) for subsequent feature extraction. The preprocessed image data are stored in a unified format for use by subsequent modules. Through denoising processing and normalization processing, the data quality can be ensured, and the interference of noise on subsequent feature extraction can be reduced.

[0057] According to an embodiment of the present invention, the data processing based on the sample data to obtain a training data set specifically includes: Clustering the normal samples in the sample data into multiple clusters to simulate a heterogeneous normal distribution to obtain a normal data set; Randomly sampling the abnormal samples in the sample data and combining with a pseudo-abnormal sample generation algorithm to construct an abnormal data set; Obtaining the training data set based on the normal data set and the abnormal data set.

[0058] It should be noted that in this embodiment, the k-means clustering algorithm is used to automatically cluster the normal samples. Among them, the normal samples in the sample data are divided into multiple clusters, and each cluster represents a sub-distribution of the normal data. During the clustering process, the division is performed according to the feature similarity of the data to ensure the difference between different clusters. Correspondingly, the clustering result is used to simulate the heterogeneous distribution of the normal data.

[0059] Further, randomly sample from the abnormal data in the sample data, and combine with the pseudo-abnormal sample generation algorithm to automatically construct multiple heterogeneous abnormal sub-datasets. Among them, through methods such as data augmentation (such as rotation, scaling) and noise injection (such as Gaussian noise), samples similar to real abnormal samples but with certain differences are generated. Each sub-dataset contains normal samples and abnormal samples to ensure the diversity of abnormal data.

[0060] According to an embodiment of the present invention, when training a preset plurality of lens defect detection sub-models using the training dataset, the training process further includes dynamically adjusting the weights of the sub-models, specifically including: Train a plurality of lens defect detection sub-models using the training dataset. Among them, each sub-model is optimized using a preset loss function. The loss function includes a classification loss that measures the classification accuracy of the model for abnormal samples and normal samples, and a regularization term that prevents the model from overfitting. Stop iterative training until the loss function is minimized. Dynamically adjust the weights of each sub-model based on the training dataset. Among them, calculate the loss value of each sub-model during training to obtain a performance parameter, and use a time series model to model the performance parameter of the sub-model to dynamically adjust the weights.

[0061] It should be noted that in this embodiment, a plurality of lens defect detection sub-models are trained using the training dataset. Among them, each sub-model focuses on learning a specific abnormal distribution and is optimized using a loss function. Correspondingly, the loss function includes a classification loss that measures the classification accuracy of the model for abnormal samples and normal samples, and a regularization term that prevents the model from overfitting. During the training process, adjust the model parameters until the loss function is minimized and stop iterative training.

[0062] Further, dynamically adjust the weights of each sub-model based on the training dataset and perform training in combination with historical data to dynamically adjust the weights of each sub-model. Among them, calculate the performance performance (such as loss value) of each sub-model in historical training, preferentially increase the weights of the sub-models with better performance, and at the same time give a certain adjustment space to the sub-models with poor performance. Finally, use the Softmax function to normalize the weights to ensure the rationality of weight adjustment.

[0063] According to an embodiment of the present invention, weighted aggregation calculation is performed based on the output results of each sub-model to obtain an abnormal score, and a defect detection result of the current sample data is output based on the abnormal score, specifically including: Perform weighted aggregation calculation by multiplying the output result of each sub-model by the corresponding weight to obtain the abnormal score; Perform threshold judgment based on the abnormal score to output whether the current sample data is a defective abnormality, and output the judgment result as the defect detection result.

[0064] It should be noted that in this embodiment, the output results of multiple sub-models are weighted and aggregated. Among them, the output result of each sub-model is multiplied by its corresponding weight for weighted aggregation, and then the anomaly score is calculated. Furthermore, a threshold judgment is performed based on the anomaly score to output whether the current sample data is a defect anomaly, and the judgment result is output as the defect detection result.

[0065] Figure 4 The block diagram of a lens defect detection model test system according to the present invention is shown.

[0066] As Figure 4 shown, the present invention discloses a lens defect detection model test system, including a memory and a processor. The memory includes a program for the lens defect detection model test method. When the program for the lens defect detection model test method is executed by the processor, the following steps are implemented: Obtain test data; Input the test data into the lens defect detection model to obtain a model result; Output externally based on the model result.

[0067] It should be noted that in this embodiment, the content of testing using the lens defect detection model is described. Among them, first, test data is obtained, then the test data is input into the lens defect detection model to obtain a model result, and finally, an external output is made based on the model result.

[0068] Specifically, in the embodiment of lens defect detection, the lens defect detection model in this embodiment is tested on a lens defect detection data set with five channels. The experimental results show that the method in this embodiment is superior to existing mainstream methods in terms of the AUROC (Area Under the Receiver Operating Characteristic curve) index. The specific data is as follows: the AUROC index of the method in this embodiment is "0.92", while the AUROC index of existing mainstream methods is "0.77". For unseen anomaly types, the accuracy of the method of the present invention is "88%", and the accuracy of existing mainstream methods is "55%". This result proves the effectiveness and superiority of this method in the task of detecting lens defects, can more accurately identify abnormal samples, and has high practical application value.

[0069] Specifically, in the embodiments of cross-domain testing, for the test datasets of different lens types, the lens defect detection model in this embodiment performs excellently in cross-domain detection tasks. The specific data is as follows: In cross-domain testing, the accuracy rate of the model in this embodiment reaches "91%", proving its good generalization ability. Correspondingly, compared with other methods, the accuracy rate in cross-domain testing is only "78%", and the model of the present invention has obvious advantages.

[0070] The fifth aspect of the present invention provides a computer-readable storage medium, which includes a program for a method of training a lens defect detection model. When the program for the method of training a lens defect detection model is executed by a processor, the steps of a method of training a lens defect detection model as described in any one of the above are implemented.

[0071] A method of training a lens defect detection model, a testing method, and a readable storage medium disclosed by the present invention can utilize multi-channel information to simulate complex heterogeneous abnormal distributions. Through multi-channel heterogeneous abnormal distribution modeling and a collaborative learning mechanism, the accuracy and generalization performance of lens defect detection are significantly improved, overcoming the limitations of traditional methods, and are particularly suitable for lens defect detection and other scenarios requiring high-precision detection.

[0072] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical, or other forms.

[0073] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units; they can be located in one place or distributed to multiple network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0074] In addition, in each embodiment of the present invention, the various functional units can all be integrated in one processing unit, or each unit can be separately used as a unit, or two or more units can be integrated in one unit; the above integrated units can be implemented in the form of hardware, or in the form of hardware plus software functional units.

[0075] Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps including those of the above method embodiments. The foregoing storage medium includes various media that can store program codes, such as removable storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs.

[0076] Alternatively, if the above integrated unit of the present invention is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiments of the present invention, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the various embodiments of the present invention. The foregoing storage medium includes various media that can store program codes, such as removable storage devices, ROM, RAM, magnetic disks, or optical discs.

Claims

1. A method for training a lens defect detection model, characterized in that Including the following steps: Read multi-channel image data and perform preprocessing to obtain sample data for different channels; Perform data processing based on the sample data to obtain a training dataset, where the training dataset includes a normal dataset and an abnormal dataset; Use the training dataset to train a plurality of preset lens defect detection sub-models, and during the training process, dynamically adjust the weights of the sub-models; Perform weighted aggregation calculation based on the output results of each sub-model to obtain an abnormal score, and output the defect detection result of the current sample data based on the abnormal score.

2. The method for training a lens defect detection model according to claim 1, wherein The step of reading multi-channel image data and performing preprocessing to obtain sample data for different channels specifically includes: The multi-channels include a first channel, a second channel, a third channel, a fourth channel, and a fifth channel, where The first channel includes a coaxial light grayscale image for detecting standard defects; The second channel includes a laser projection image for detecting lens molding defects; The third channel includes a multi-level laser color image for detecting minute glass structure defects; The fourth channel includes a coaxial light blue image for detecting fine defects; The fifth channel includes a laser grayscale image for detecting edge chipping and burr defects; Read the image data of the multi-channels and perform preprocessing to obtain the sample data, where the preprocessing methods include denoising and normalization processing.

3. A method for training a lens defect detection model according to claim 2, characterized in that The step of performing data processing based on the sample data to obtain a training dataset specifically includes: Cluster the normal samples in the sample data into multiple clusters to simulate a heterogeneous normal distribution to obtain a normal dataset; Randomly sample the abnormal samples in the sample data and combine them with a pseudo-abnormal sample generation algorithm to construct an abnormal dataset; Obtain the training dataset based on the normal dataset and the abnormal dataset.

4. A method for training a lens defect detection model according to claim 3, characterized in that The step of using the training dataset to train a plurality of preset lens defect detection sub-models, and during the training process, dynamically adjust the weights of the sub-models specifically includes: Use the training dataset to train a plurality of lens defect detection sub-models, where each sub-model is optimized using a preset loss function, and the loss function includes a classification loss that measures the classification accuracy of the model for abnormal samples and normal samples and a regularization term to prevent the model from overfitting, and stop iterative training until the loss function is minimized; Dynamically adjust the weights of each sub-model based on the training dataset, where calculate the loss value of each sub-model during training to obtain a performance parameter, and use a time series model to model the performance parameter of the sub-model to dynamically adjust the weights.

5. A method for training a lens defect detection model according to claim 4, characterized in that, The step of performing weighted aggregation calculation based on the output results of each sub-model to obtain an abnormal score, and outputting the defect detection result of the current sample data based on the abnormal score specifically includes: Perform weighted aggregation calculation by multiplying the output result of each sub-model by the corresponding weight to obtain the abnormal score; Perform threshold judgment based on the abnormal score to output whether the current sample data is a defect anomaly, and output the judgment result as the defect detection result.

6. A method for testing a lens defect detection model, characterized in that, Applied to the lens defect detection model obtained by the lens defect detection model training method according to any one of claims 1 to 5, where the method includes the following steps: Obtain test data; Input the test data into the lens defect detection model to obtain a model result; Output externally based on the model result.

7. A lens defect detection model training system, characterized in that, It includes a memory and a processor. The memory includes a lens defect detection model training method program. When the lens defect detection model training method program is executed by the processor, the following steps are implemented: Read multi-channel image data and perform preprocessing to obtain sample data of different channels; Perform data processing based on the sample data to obtain a training data set, where the training data set includes a normal data set and an abnormal data set; Use the training data set to train a plurality of preset lens defect detection sub-models, and during the training process, the weights of the sub-models are also dynamically adjusted; Perform weighted aggregation calculation based on the output results of each sub-model to obtain an abnormal score, and output the defect detection result of the current sample data based on the abnormal score.

8. A lens defect detection model training system according to claim 7, characterized in that The step of reading multi-channel image data and performing preprocessing to obtain sample data of different channels specifically includes: The multi-channels include a first channel, a second channel, a third channel, a fourth channel, and a fifth channel, where The first channel includes a coaxial light grayscale image for detecting standard defects; The second channel includes a laser projection image for detecting lens molding defects; The third channel includes a multi-level laser color image for detecting tiny glass structure defects; The fourth channel includes a coaxial light blue image for detecting fine defects; The fifth channel includes a laser grayscale image for detecting edge chipping and burr defects; Read multi-channel image data and perform preprocessing to obtain the sample data, where the preprocessing methods include denoising and normalization processing.

9. A lens defect detection model testing system, characterized in that, It includes a memory and a processor. The memory includes a lens defect detection model testing method program. When the lens defect detection model testing method program is executed by the processor, the following steps are implemented: Obtain test data; Input the test data into the lens defect detection model to obtain a model result; Output externally based on the model result.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a lens defect detection model training method program. When the lens defect detection model training method program is executed by a processor, the steps of a lens defect detection model training method as described in any one of claims 1 to 5 and / or a lens defect detection model testing method as described in claim 6 are implemented.

Citation Information

Patent Citations

  • Joint multi-channel product defect classification method based on deep learning

    CN111709918A

  • Welding defect detection method and device, electronic equipment and storage medium

    CN111862067A

  • Defect detection method and device, electronic equipment and readable storage medium

    CN118823513A

  • Fitting prediction method, system and equipment of machine learning model and medium

    CN119046676A