Optical element defect recognition and grading method based on small sample learning and fine segmentation
By employing a few-sample learning and fine segmentation method, combined with multi-angle image acquisition and a deep neural network model, we have achieved efficient identification and dynamic grading of defects in precision optical components. This solves the problems of scarce samples, insufficient identification accuracy, and poor system adaptability, thereby improving detection efficiency and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- FUJIAN HITRONICS TECH INC
- Filing Date
- 2026-05-19
- Publication Date
- 2026-07-10
AI Technical Summary
Existing technologies for defect detection of precision optical components suffer from problems such as scarce samples, insufficient recognition accuracy, rigid quality grading, and the inability of the system to adapt, resulting in low detection efficiency and low accuracy.
This method employs a few-shot learning and fine segmentation approach. It involves image acquisition and standardization preprocessing under multiple angles and lighting conditions, combined with a deep neural network model based on meta-learning or transfer learning frameworks. The model is trained in two stages using a small number of labeled samples and a large number of unlabeled samples. By combining a cascaded fine segmentation network and multi-feature fusion hierarchical decision-making, the method achieves preliminary defect localization, fine segmentation, and dynamic quality grading. The model is then optimized through a feedback closed-loop mechanism.
Achieving high-precision defect identification and classification with a small number of labeled samples significantly improves the segmentation accuracy of minute defects, adapts to the needs of different batches and types of optical components, has continuous iterative optimization capabilities, and maintains long-term stable detection performance.
Smart Images

Figure CN122368034A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent detection technology for surface defects of precision optical components, specifically involving a defect identification and classification method for optical components based on small sample learning and fine segmentation. Background Technology
[0002] Precision optical components are key parts of core equipment such as laser systems, imaging devices, and semiconductor lithography devices. Defects such as scratches, pits, stains, microcracks, and chipping on their surfaces can directly affect optical performance, leading to decreased beam quality, blurred images, increased energy loss, and even equipment failure. Therefore, the accuracy and efficiency requirements for surface quality inspection are extremely high.
[0003] Traditional inspection methods mostly rely on manual visual inspection or machine learning models based on large-scale labeled samples. Manual visual inspection is highly subjective, inefficient, and prone to causing visual fatigue during long periods of work. It is difficult to control the rates of missed and false detections, and quantitative assessment is not possible. Machine learning models based on large-scale labeled samples are limited by the difficulty and high cost of obtaining defect samples of precision optical components. Due to the high manufacturing cost of optical components and the extremely low proportion of defective products, it is difficult to obtain a large number of labeled samples to support model training. In small sample scenarios, it is difficult to accurately identify different types of defects and to finely segment defect areas to support accurate quality grading.
[0004] The existing technical solutions in this field generally suffer from the following four main problems:
[0005] First, there is the problem of scarce defect samples. Conventional deep learning methods require a large number of labeled samples to train the model, but defect samples for optical components are scarce, the labeling cost is extremely high, and the model has poor adaptability to new defects and cannot iterate quickly. When faced with special defect types of customized components, a large number of samples need to be collected again for training, which seriously prolongs the debugging cycle of new product detection.
[0006] Second, there is the problem of insufficient accuracy in defect recognition. Traditional machine vision methods rely on manually designed thresholds, edge detection, and other rules to identify defects. This not only results in extremely low recognition rates for complex, small, low-contrast, and blurred-edge defects, but is also easily affected by lighting and imaging interference. The recognition method based on a single segmentation model lacks sufficient segmentation accuracy, making it difficult to accurately capture the edges and shapes of defects. This leads to errors in subsequent feature extraction and grading, and it is very easy to miss tiny defects that affect optical performance.
[0007] Third, there is a lack of flexibility in quality grading. Fixed-rule quality grading methods have fixed grading thresholds, which cannot adapt to the differentiated quality standards of different batches and types of components. The grading results are rigid and cannot meet the quality inspection needs of multiple categories of optical components.
[0008] Fourth, there is the problem of the system's inability to adapt. The existing system lacks a continuous iterative optimization mechanism, making it unable to adapt to changes in the production environment and new defect patterns. After long-term operation, its performance is prone to decline, making it difficult to maintain stable detection accuracy. Summary of the Invention
[0009] To address the shortcomings and deficiencies of existing technologies, this invention provides a method and system for identifying and classifying defects in optical components based on few-sample learning and fine segmentation. The scheme first acquires images of the surface of precision optical components under multiple angles and illumination conditions, and eliminates imaging interference and highlights defect features through standardized preprocessing to obtain standardized input images. Then, a deep neural network model based on meta-learning or transfer learning frameworks is constructed. Using a small number of labeled precision optical component defect samples combined with a large number of unlabeled or general domain defect samples, the model is trained using a two-stage strategy combining inner-loop meta-training and outer-loop domain adaptation. The inner-loop meta-training simulates rapid parameter adaptation for new defect categories through gradient updates, enabling the model to quickly generalize to unknown defects. The outer-loop domain adaptation aligns the feature distributions of the source and target domains in the reproducing kernel Hilbert space using maximum mean difference loss, reducing the impact of cross-domain offset on recognition performance. This allows for preliminary identification of defect regions even when target domain defect samples are scarce. Next, the standardized input image is input into the trained model to obtain preliminary defect localization results. A cascaded fine segmentation network is used to perform pixel-level iterative refinement of the preliminary localized region. This cascaded fine segmentation network introduces a spatial attention mechanism and an edge perception module. Attention weights are generated by fusing low-level detail features and high-level semantic features from the encoder to enhance the sensitivity to defect boundaries. A composite loss function combining Dice loss and edge perception loss is used for training, gradually converging to generate a high-precision defect fine segmentation mask. Finally, multi-dimensional quantitative features such as morphology, texture, and contrast are automatically extracted from the defect fine segmentation mask and input into the grading decision module. Combining the influence weights of each defect feature on optical performance with a grading threshold dynamically adjusted based on the smoothing coefficient and batch data statistics, the severity level of defects is classified, and a defect distribution map and quality level label are output. This method can complete model construction and accurate defect identification and grading with a small number of labeled samples, and the model can achieve continuous self-optimization through an optional feedback closed-loop mechanism.
[0010] The specific technical solution adopted by this invention to solve its technical problem is as follows:
[0011] This invention first provides a method for identifying and classifying defects in optical components based on few-sample learning and fine segmentation, comprising the following steps:
[0012] Images of the surface of precision optical components are acquired under multiple angles and illumination conditions, and then standardized preprocessing is performed to obtain standardized input images.
[0013] In this step, multi-angle acquisition is achieved through a precision electric rotary platform, which allows the optical elements to rotate in fixed-angle steps, covering multiple viewing angles within a predetermined range. Multiple illumination conditions are achieved by adjusting the incident angle and light intensity of the illumination system to comprehensively cover the reflective characteristics of defects under different viewing angles and illuminations, enhancing the robustness of subsequent defect identification. Standardized preprocessing sequentially includes image denoising, contrast enhancement, and geometric correction, used to eliminate noise interference during imaging, highlight low-contrast defect features, and correct lens distortion, providing consistent input data for the subsequent defect identification model.
[0014] A deep neural network model based on meta-learning or transfer learning framework is constructed. A small number of labeled precision optical component defect samples are combined with a large number of unlabeled or general defect samples. The model is trained by a two-stage strategy that combines inner loop meta-training and outer loop domain adaptation. The inner loop meta-training simulates the rapid parameter adaptation of new defect categories, while the outer loop domain adaptation aligns the feature distributions of the source domain and the target domain through maximum mean difference loss.
[0015] The core of this two-stage training strategy lies in the following: In the meta-training stage, the initial parameters of the model are optimized through an inner-loop gradient update, simulating a single-step parameter fine-tuning process for unknown new defect categories, enabling the model to quickly adapt to new tasks. In the feature space adaptation stage, a maximum mean difference loss is introduced to measure and reduce the feature distribution difference between the source and target domains in the regenerating kernel Hilbert space, mitigating the generalization performance degradation caused by domain shift between general defect samples and precision optical component defect samples. By using the meta-training loss and the domain adaptation loss together as the overall optimization objective for outer-loop updates, the model can achieve preliminary localization of defect regions even when defect samples in the target domain are scarce.
[0016] The model is trained by inputting a standardized input image to obtain the preliminary defect localization result. A cascaded fine segmentation network is used to perform pixel-level iterative refinement of the preliminary localization region. The cascaded fine segmentation network introduces a spatial attention mechanism and an edge perception module, and integrates low-level detail features and high-level semantic features to enhance the boundary segmentation accuracy. It is trained using a composite loss function of Dice loss and edge perception loss to generate a fine defect segmentation mask.
[0017] In this step, the spatial attention mechanism in the cascaded fine segmentation network allocates higher attention weights to the defect boundary region by fusing feature maps from different levels of the encoder, enabling the network to focus on the transition region between the defect and the background. The edge-aware module further enhances the sensitivity to the defect contour by introducing edge gradient information. The Dice loss in the composite loss function measures the degree of region overlap between the predicted mask and the ground truth mask, while the edge-aware loss constrains the gradient consistency between the predicted and ground truth boundaries. The weighted combination of these two losses allows the network to simultaneously optimize region segmentation accuracy and boundary localization accuracy during training. During iterative refinement, the current refinement output is updated to a new preliminary localization region, and feature extraction and segmentation are performed again. After multiple iterations, the network gradually converges to a high-precision fine-segmentation mask for the defect.
[0018] The morphological, texture, and contrast multidimensional quantitative features are extracted from the defect fine segmentation mask and input into the grading decision module. Combining the impact weight of defects on optical performance with the dynamic grading threshold based on the combination of smoothing coefficient and batch data statistics, the severity level of defects is classified and the defect distribution map and quality level label are output.
[0019] In this step, morphological features include defect area and perimeter. The area is obtained by counting pixels in the finely segmented mask, and the perimeter is calculated using the boundary pixel chain code. Texture features are calculated based on the gray-level co-occurrence matrix, including at least contrast. The contrast feature is the difference in average pixel values between the defect area and the background area. The grading decision module employs a multi-feature fusion classifier, trained on historical data to obtain the influence weights of different defect features on optical performance. This ensures that the grading results consider not only the geometric scale of the defect but also the actual impact of defect type, location, and other factors on optical performance. The grading threshold is dynamically updated based on a smoothing coefficient and the statistical mean of defect features in the current batch. This allows the grading standard to smoothly adapt to the quality judgment requirements of different batches of components, avoiding overly strict or lenient grading caused by a fixed threshold.
[0020] In a preferred embodiment, the method further includes: constructing a feedback loop between the grading results and the newly collected sample data reviewed by experts; when the number of newly labeled samples reaches a preset threshold or the segmentation accuracy of the model validation set decreases by more than a set amount, using an online stochastic gradient descent algorithm to update the model weights only on the newly added samples without full retraining; and adaptively calibrating the grading threshold based on the misjudgment rate deviation of production quality feedback.
[0021] This feedback loop mechanism enables the system to continuously absorb high-quality new labeled samples during operation, incrementally optimize the model in a lightweight manner, and drive the adaptive calibration of the classification threshold through the feedback of the false positive rate deviation, ensuring that the system can adapt to new defect patterns and changes in the production environment during long-term operation and maintain stable detection performance.
[0022] In some specific embodiments of the present invention, the standardized preprocessing sequentially employs Gaussian filtering for noise reduction, contrast-limited adaptive histogram equalization enhancement, and radial distortion correction. Multi-angle, multi-illumination acquisition can reveal hidden features of defects such as micro-scratches being more apparent under grazing light, while preprocessing eliminates imaging interference and enhances local contrast. The two processes work together to highlight the features of low-contrast defects.
[0023] In some specific embodiments of the present invention, the training data is divided into a support set containing a small number of labeled target domain samples and a query set containing a large number of unlabeled or general domain samples. The inner loop meta-training simulates a single-step fine-tuning process for new defect categories through gradient updates, while the outer loop domain adaptation minimizes the maximum mean difference between the source and target domain features, thereby achieving both rapid model adaptation and cross-domain generalization. Model initialization uses pre-trained weights from the ImageNet dataset to introduce general visual knowledge. Data augmentation techniques such as random rotation and cropping are used on the query set samples to enhance sample diversity. An early stopping mechanism is implemented during training to prevent overfitting.
[0024] In some specific embodiments of the present invention, the cascaded fine segmentation network adopts a two-stage structure. The first stage outputs a preliminary defect localization probability map and binarizes it into a candidate region mask through thresholding. The second stage focuses on the defect boundary region through a spatial attention mechanism, extracts edge features in conjunction with an edge perception module, and performs end-to-end training using a composite loss function weighted by Dice loss and edge perception loss. The network iterates and refines the preliminary localization result multiple times. During each iteration, the preliminary localization result is updated and features are extracted and segmented again, gradually converging to a high-precision defect segmentation mask.
[0025] The present invention also provides an optical element defect identification and grading system for implementing the above method, comprising:
[0026] The image acquisition and preprocessing unit is used to perform multi-angle, multi-light image acquisition and standardization preprocessing.
[0027] The few-sample model training unit is used to perform two-stage few-sample adaptive model training. Through an optimization strategy that combines inner loop training with outer loop domain adaptation, the model can obtain the initial localization capability of defect regions under the condition of scarce target domain samples.
[0028] The defect fine segmentation unit is used to perform cascaded defect region pixel-level fine-tuning and mask generation. By introducing an attention mechanism and an edge awareness module, it performs high-precision segmentation of defect boundaries.
[0029] The multi-feature fusion hierarchical unit is used to perform multi-dimensional feature extraction and dynamic threshold quality grading. The quality level is output by dynamically adjusting the grading threshold based on the weight of the impact of defects on optical performance and the smoothing coefficient.
[0030] The closed-loop iterative optimization unit is used to perform triggered incremental model learning and hierarchical rule calibration, enabling the system to continuously adapt to new defect patterns and changes in the production environment.
[0031] Compared with existing technologies, this invention and its preferred solutions effectively reduce the dependence on labeled defect samples, enabling the rapid construction of high-precision detection models under conditions of a small number of samples; significantly improve the segmentation accuracy of small, low-contrast defects, and accurately capture defect boundaries and morphological features; achieve dynamic adaptation of quality grading standards, and meet the quality inspection needs of different batches and types of optical components; and have continuous iterative optimization capabilities, adapting to changes in the production environment and new defect patterns, and maintaining stable detection performance over the long term. Attached Figure Description
[0032] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments:
[0033] Figure 1 This is a schematic diagram of the method flow according to an embodiment of the present invention. Detailed Implementation
[0034] To make the features and advantages of the present invention more apparent and understandable, specific embodiments are described below in detail:
[0035] It should be noted that the following detailed descriptions are exemplary and intended to provide further explanation of this application. Unless otherwise specified, all technical and scientific terms used in this specification have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.
[0036] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0037] This invention provides a method and system for automatic identification and quality grading of surface defects in precision optical components based on few-sample adaptive learning and fine segmentation of defect regions. It is an intelligent detection technology solution that addresses the small, diverse, and easily confused defects on the surface of precision optical components by integrating a few-sample adaptive learning algorithm with high-precision fine segmentation of defect regions. This achieves automated defect identification and accurate quality grading, and is primarily applied to the quality control of various precision optical components in high-end manufacturing fields such as industrial lasers and optical communications. The core idea of this patent is to construct a closed-loop system around the requirements of few-sample scenarios and fine segmentation. Specifically, it involves: first, acquiring high-quality image input through multi-angle, multi-light illumination acquisition and standardized preprocessing; then, constructing a few-sample adaptive model based on a meta-learning or transfer learning framework, using a small number of labeled samples combined with a large number of unlabeled or common defect samples to complete model training, solving the problem of sample scarcity; next, using a cascaded fine segmentation network to perform pixel-level refinement of the initially located defects, extracting multi-dimensional features such as morphology and texture; then, dynamically adjusting the threshold based on a multi-feature fusion grading module to complete quality grading; and finally, continuously optimizing the model and grading rules through a feedback loop of expert review samples. Its highlight lies in combining few-sample adaptive learning with fine segmentation depth, while constructing an iterative optimization closed-loop mechanism that balances the feasibility of few-sample scenarios with high accuracy in recognition and classification.
[0038] In the data acquisition and preprocessing stage, a high-resolution industrial camera equipped with a 50-megapixel CMOS sensor and a uniform illumination system are used. A precision electric rotating platform rotates the optical elements at fixed angles to acquire multi-view images within a 0-360 degree range. An adjustable ring LED array illumination system is employed, allowing for acquisition under various illumination conditions by adjusting the incident angle and intensity of the light. The acquired raw images are then sequentially subjected to Gaussian filtering for noise reduction, contrast-limited adaptive histogram equalization to enhance local contrast, and radial distortion correction to eliminate lens distortion. This effectively suppresses noise, highlights low-contrast defects, and achieves pixel-level image standardization, eliminating imaging interference and highlighting defect features, resulting in standardized input images. This provides high-quality, standardized input data for subsequent defect identification.
[0039] In the construction and training of the few-shot adaptive learning model, to address the problem of scarce defect samples for precision optical components, a deep neural network model based on the Model-Independent Meta-Learning (MAML) framework is constructed, using ResNet-18 as the basic feature extractor. The input data is divided into a support set containing a small number of labeled precision optical defect samples and a query set containing a large number of unlabeled or general defect samples. Data augmentation techniques such as random rotation and cropping are used on the query set samples to improve sample diversity. Model initialization uses pre-trained weights from the ImageNet dataset to introduce general visual knowledge. The training process is divided into two stages: meta-training and feature space adaptation. In the meta-training stage, an inner loop gradient update simulates the fine-tuning process for new defect categories. In the feature space adaptation stage, maximum mean difference loss is introduced to align the feature distributions of the source and target domains. An early stopping mechanism is implemented during training to prevent overfitting, and the defect category probability is output through a softmax layer. By using a small number of labeled precision optical component defect samples and a large number of unlabeled or related general defect samples, a two-stage adaptive learning strategy of rapid fine-tuning of model parameters and adaptive feature space is adopted to train the model. This enables the model to quickly learn new defect category features under small sample conditions, acquire initial defect recognition capabilities, significantly reduce dependence on labeled samples, and improve the model's generalization ability under small sample conditions.
[0040] In the fine segmentation and feature extraction stage of the defect region, the preprocessed image is input into the trained model to obtain the preliminary defect localization result. The fine segmentation of the defect region adopts a cascaded network structure. The first stage outputs a preliminary defect localization probability map and binarizes it into a candidate region mask. The second stage introduces a spatial attention mechanism module to focus on the defect boundary region, enhancing boundary sensitivity through weighted fusion of high and low layer features. Training employs a composite loss function combining Dice loss and edge-aware loss, iteratively refined 2-3 times until convergence, performing pixel-level precise segmentation of the initially located defect region, accurately segmenting the defect boundary and morphology, solving the problem of insufficient accuracy of a single segmentation model. Subsequently, multi-dimensional quantitative features of the defect are automatically extracted from the fine segmentation results, including morphological features such as calculating the defect area based on the fine segmentation mask and calculating the perimeter through the boundary pixel chain code; texture features calculated based on the gray-level co-occurrence matrix; and contrast features based on the difference between the average pixel values of the defect region and the background, providing a comprehensive and accurate quantitative basis for quality grading.
[0041] In the automatic quality grading process based on multi-feature fusion, the extracted multi-dimensional defect features are input into the grading decision module. This module employs a softmax classifier based on multi-feature fusion, trained using historical data to obtain weight vectors reflecting the impact of features on optical performance, and calculates the probability distribution of each severity level. By analyzing the influence weights of defect size, type, and location on optical performance, and combining this with a dynamically adjustable grading threshold—which is dynamically adjusted using a smoothing coefficient and the mean of the current batch of defect data—the rigidity of fixed rules is avoided. This adapts to the quality standard requirements of different batches and types of optical components, classifying defects into different severity levels, and finally outputting a defect distribution map and corresponding quality level label for each component.
[0042] In the system iterative optimization and online adaptive phases, a feedback loop is constructed between the grading results and newly collected sample data reviewed by experts. The system iterative optimization adopts a triggered update mechanism. Incremental learning is initiated when the number of newly labeled samples reaches a preset threshold or the segmentation accuracy of the model validation set decreases by more than a set amount. The online stochastic gradient descent algorithm is used to optimize model weights only on new samples, without requiring full retraining. Incremental learning is used to fine-tune the adaptive learning model, optimizing its recognition and segmentation performance. At the same time, the grading threshold is calibrated based on the misjudgment rate deviation from production quality feedback, enabling the system to continuously adapt to new defect patterns and changes in the production environment, ensuring that the system can continuously adapt to new defect patterns and changes in the production environment, and achieving continuous performance improvement.
[0043] This invention also provides an automatic identification and quality grading system for surface defects of precision optical components that implements the above-described method. The system includes: an image acquisition unit, consisting of a high-resolution industrial camera, a ring LED lighting system, and a precision electric rotating platform, for acquiring images from multiple angles and under multiple illuminations; a data preprocessing unit, for denoising, contrast enhancement, and geometric correction of the original images; a few-shot model training unit, for constructing and training an adaptive model based on meta-learning or transfer learning; a defect segmentation and feature extraction unit, for achieving fine segmentation of defect regions and multi-dimensional feature extraction; a quality grading unit, for performing dynamic grading through multi-feature fusion; an iterative optimization unit, for constructing a feedback loop to continuously optimize the model and grading rules; and a visualization output unit, for generating defect distribution maps and quality level labels. The system implements model training under the PyTorch framework, and a grading module is deployed in an embedded system to meet real-time processing requirements.
[0044] This invention is applied to quality control throughout the entire manufacturing process of precision optical components, enabling efficient and accurate identification and automated quality grading of surface defects. Utilizing a technology based on small-sample adaptive learning and fine segmentation of defect regions, surface images of optical components can be acquired in real time during mass production. For various minute defects such as scratches, pitting, and chipping, even with only a small number of defect samples, model adaptation can be quickly completed, accurately segmenting the specific location, shape, and size of the defects. Components are automatically classified into four grades: superior, qualified, rework, and scrap, replacing the inefficient manual visual inspection. In the small-batch customized production of high-end precision optical prisms, facing the special defect types of customized components, a suitable detection model can be quickly built without a large number of labeled samples to complete defect identification and grading, shortening the debugging cycle for new product inspection. In the factory inspection of optical components, high-precision identification and grading of defects such as microcracks and stains on the component surface that easily affect optical performance can be achieved, ensuring the reliability and stability of the components. This invention has wide applications in fields such as optical manufacturing, industrial lasers, and optical communication. Compared with traditional methods, it can reduce sample labeling costs by more than 60%, improve defect identification accuracy to more than 98%, and shorten the adaptation cycle of new defects to 1 / 3 of traditional methods. It effectively solves the problems of sample scarcity, insufficient segmentation accuracy, rigid grading, and poor system adaptability in the identification of defects in precision optical components, and achieves an improvement in identification rate of more than 15% even when samples are scarce.
[0045] Key technological innovations of this solution also include: For small-sample training, an optimization strategy combining inner-loop gradient updates for simulated fine-tuning and outer-loop domain adaptive loss is employed, significantly improving the model's defect identification accuracy with a small number of samples; Fine defect segmentation utilizes an iterative refinement mechanism, repeatedly updating the initial localization results and re-segmenting to gradually converge to a high-precision defect mask, further improving the accuracy of segmentation boundaries; Quality grading results are visualized, automatically generating a distribution map of labeled defect locations and grades, and outputting a standardized quality grade file for easy production traceability and management; Incremental learning employs a lightweight implementation, updating only newly labeled samples using stochastic gradient descent, eliminating the need for full model retraining, significantly reducing computational overhead and training time while ensuring performance optimization.
[0046] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments, but this is not intended to limit the present invention.
[0047] like Figure 1 As shown, the implementation of the embodiment of the present invention includes the following steps performed sequentially:
[0048] Multi-angle image acquisition: Using a high-resolution industrial camera and a uniform illumination system, images of the surface of precision optical components are acquired from multiple angles and under multiple lighting conditions.
[0049] Image preprocessing: The acquired raw images are sequentially subjected to denoising, contrast enhancement, and geometric correction to obtain a standardized input image;
[0050] Building few-shot models: Constructing deep neural network models based on meta-learning or transfer learning frameworks;
[0051] Fusion of annotations and general samples: A small number of annotated precision optical defect samples are fused with a large number of unannotated or general defect samples from related fields;
[0052] Adaptive training and fine-tuning: The model is trained using a two-stage strategy of rapid fine-tuning of model parameters and adaptive feature space.
[0053] Output preliminary defect localization: Input the preprocessed image into the trained model to obtain the preliminary defect localization result;
[0054] Fine segmentation of defective regions: A cascaded fine segmentation network with an attention mechanism or edge perception module is used to perform pixel-level iterative refinement of the initially located defective regions.
[0055] Extracting multidimensional defect features: Automatically extracting multidimensional quantitative features such as morphology, texture, contrast, and area of defects from the fine segmentation results;
[0056] Multi-feature fusion grading: The extracted multi-dimensional defect features are input into the grading decision module, and quality grading is performed in combination with dynamically adjustable grading thresholds;
[0057] Output distribution diagram and grade: Defect distribution diagram of output components and corresponding quality grade labels;
[0058] Expert review and quality feedback: The grading results will be submitted to experts for review, and quality feedback information will be generated.
[0059] Incremental learning and rule calibration: The adaptive learning model is fine-tuned using new sample data reviewed by experts, and the grading rules are calibrated based on quality feedback;
[0060] The calibrated model and grading rules are fed back to the adaptive training and fine-tuning and multi-feature fusion grading steps, forming a closed-loop iterative optimization mechanism.
[0061] The specific implementation details of each step are as follows:
[0062] Step 1: Data Acquisition and Preprocessing: First, using a high-resolution industrial camera and a uniform illumination system, images of the surface of the precision optical component are acquired under multi-angle and multi-illumination conditions. Then, the acquired raw images are preprocessed, including image denoising, contrast enhancement, and geometric correction, to eliminate interference during the imaging process and highlight defect features. This step provides high-quality, standardized input data for subsequent defect identification. The specific implementation method of this step is as follows:
[0063] During the data acquisition phase, a high-resolution industrial camera, such as one equipped with a 50-megapixel CMOS sensor, is used with a resolution of 8192×6144 pixels and a frame rate of 30fps to ensure the capture of sub-micron level defect details. A uniform illumination system uses a ring-shaped LED array with an adjustable light intensity range of 50-1000 lux. A diffuser plate ensures illumination uniformity error of less than 5%, avoiding hotspots and shadow interference. Multi-angle acquisition is achieved through a precision motorized rotating platform. The component rotates in fixed angular steps (e.g., 5-degree intervals), covering a range of 0-360 degrees and acquiring 72 viewpoint image sequences. Multiple illumination conditions are simulated by programming the LED array, adjusting the incident angle from 0 degrees (vertical illumination) to 90 degrees (grazing illumination) in 10-degree increments, while simultaneously adjusting the light intensity to mimic different environmental conditions. This comprehensively covers the reflection characteristics of defects under different viewing angles and illumination levels, enhancing the robustness of subsequent defect identification. The camera model employs a perspective projection formula. Describe the imaging process, where Image coordinate vector , World coordinate vector , The intrinsic parameter matrix includes focal length. , and the main point , It is a 3×3 rotation matrix. This is a translation vector. Accurate values are obtained through pre-calibration. , and Parameters are optimized to ensure geometric accuracy and eliminate systematic errors. The beneficial effect is that the multi-angle, multi-illumination strategy can reveal hidden features of defects, such as micro-scratches being more apparent under grazing light, significantly improving the comprehensiveness and reliability of defect detection. The preprocessing stage first involves image denoising, applying a Gaussian filtering algorithm to process the original image. The formula is:
[0064]
[0065] in The standard deviation controls the smoothing strength (typical value 1.5). It is the kernel window size (e.g., 5×5 pixels). and This is used as the pixel offset index. This effectively suppresses Gaussian noise and random interference while preserving edge details, laying the foundation for defect feature extraction. Next, contrast enhancement is performed using the Limiting Contrast Adaptive Histogram Equalization (CLAHE) method. The image is divided into 8×8 blocks, and histogram equalization transformation is applied to each block. ,in The grayscale level (e.g., 256). The probability density function is used, and interpolation between block boundaries is employed to avoid artifacts. This enhances the contrast between defects and the background, highlighting low-contrast defects such as fine stains. A beneficial effect is that CLAHE adaptively processes local regions, avoiding over-enhancing noise, ensuring uniform highlighting of defect features, and improving subsequent classification accuracy. Finally, geometric correction is performed, applying a radial distortion correction model based on camera calibration parameters, with the following formula:
[0066] and
[0067] in For normalized radial distance, and The distortion coefficients (obtained through calibration) are used to correct image distortion, eliminating barrel or pincushion distortion and achieving pixel-level standardization. The entire preprocessing workflow outputs high-quality images, eliminates imaging variations, and ensures consistency of input data.
[0068] Step 2: Construction and Training of a Small-Sample Adaptive Learning Model: Addressing the problem of scarce defect samples in precision optical components, a deep neural network model based on a meta-learning or transfer learning framework is constructed. Using a small number of labeled defect samples combined with a large number of unlabeled or related domain-specific defect samples, the model is trained through adaptive learning strategies (such as rapid fine-tuning of model parameters and adaptive feature space). This step enables the model to quickly learn the features of new defect categories with a limited number of samples, forming an initial defect recognition capability. The specific implementation method of this step is as follows:
[0069] A deep convolutional neural network (CNN) is constructed using a Model-Independent Meta-Learning (MAML) framework. The model architecture employs ResNet-18 as the basic feature extractor to handle local texture features in images of optical component defects. Input data is divided into a support set and a query set: the support set contains a small number of labeled precision optical defect samples (e.g., scratches, bubbles), with only 5-10 samples per category; the query set integrates a large number of unlabeled defect samples or general defect data from related fields (e.g., semiconductor wafer defects), enhancing sample diversity through data augmentation (e.g., random rotation, cropping). During model initialization, pre-training weights use the ImageNet dataset to introduce general visual knowledge through transfer learning, reducing reliance on labeled data. The training process employs a two-stage adaptive strategy: first, a meta-training stage is performed to optimize initial parameters for rapid adaptation to the new task; second, feature space adaptation is performed to align the feature distributions of the source domain (general defects) and the target domain (precision optical defects).
[0070] The goal of the meta-training phase is to minimize the meta-loss function, and the meta-objective is defined as:
[0071]
[0072] in Indicates the initial parameters of the model. From task distribution The meta-task of sampling Let cross-entropy be the loss function. This is the adapted model. The adaptation parameters are calculated through inner loop gradient updates:
[0073]
[0074] here The inner loop learning rate (preferably set to 0.01) supports set loss. Query set loss is calculated based on a small number of labeled samples. Generalization performance is evaluated using unlabeled samples. This meta-learning framework enables the model to converge quickly with only a small number of samples because the inner loop simulates the fine-tuning process for new defect categories, significantly improving initial recognition capabilities.
[0075] The maximum mean difference (MMD) loss is introduced in the feature space adaptation stage to reduce inter-domain distribution differences. The adaptive loss is defined as:
[0076]
[0077] in and These represent the feature vectors of the source and target domains, respectively (extracted through the last fully connected layer of the CNN). It is an adjustable tradeoff factor (preferably 0.5), and MMD is calculated as follows:
[0078]
[0079] here It is a mapping function of the reproducing kernel Hilbert space (RKHS) using a Gaussian kernel:
[0080]
[0081] Let the kernel width be 1.0. By combining the meta-loss and adaptive loss, the overall optimization objective is:
[0082]
[0083] The outer loop is updated using the Adam optimizer (learning rate 0.001, batch size 32). This feature alignment strategy effectively utilizes unlabeled data, reduces domain offset, and enables the model to generalize with high accuracy on precision optical defects.
[0084] In the engineering implementation, training is performed using the PyTorch framework, with an early stopping mechanism (terminating the model when the validation loss does not decrease for three consecutive epochs) to prevent overfitting. The model output is the defect class probability, which is normalized using a softmax layer.
[0085]
[0086] in It is the input image eigenvectors, It is the number of defect categories. and These are the classification layer weights and biases. Ultimately, the model is deployed after fine-tuning with a small number of labeled samples, forming initial recognition capabilities.
[0087] Step 3: Fine-grained segmentation and feature extraction of defect regions: The segmentation model in Step 3 shares the same basic feature extraction network as the classification model in Step 2. The preprocessed image is input into the trained model, which first outputs the preliminary location of the defect. Based on this, a cascaded or iterative fine-grained segmentation network (e.g., incorporating an attention mechanism or edge-aware module) is used to refine the initially located defect regions at the pixel level, accurately segmenting the boundaries and shapes of the defects. Subsequently, multi-dimensional quantitative features such as morphology, texture, contrast, and area of the defects are automatically extracted from the fine-grained segmentation results, providing a basis for quality grading. The specific implementation method of this step is as follows:
[0088] Preprocessed image Input a pre-trained semantic segmentation model, which is based on a convolutional neural network architecture (such as U-Net), and output a preliminary probability map of defect localization. Specifically, the model extracts features through an encoder-decoder structure, and the output layer applies a softmax function to generate the defect probability for each pixel.
[0089]
[0090] in Represents pixel coordinates, For model parameters, Optimization is achieved through training. Initial localization is achieved through threshold processing (e.g., setting a threshold). Binarization into a mask Defect candidate regions are identified. A cascaded fine-grained segmentation network is used for pixel-level refinement. The first stage is a preliminary segmentation network, and the second stage introduces a spatial attention mechanism module. This module calculates the attention weight map. Focusing on the boundary area:
[0091]
[0092] in and These are feature maps from the low-level and high-level layers of the encoder, respectively. and To enable learnable convolution weights and biases, It is the sigmoid activation function. This represents a convolution operation. The attention mechanism enhances boundary sensitivity through weighted feature fusion, effectively reducing false detections and improving edge accuracy, which is beneficial for subsequent quality grading. Refine the mask. Generated via decoder:
[0093]
[0094] in For fine-grained network parameters, This represents element-wise multiplication. A composite loss function is used during training.
[0095]
[0096] in:
[0097]
[0098] For Dice's loss, It is the real mask. It is a predictive mask. For edge-aware loss, gradient differences are calculated based on the Sobel operator. These are balancing weights, the values of which can be adjusted according to the task's requirements for boundary accuracy (preferred). The iterative process is repeated 2-3 times, with each update... This is the current refined output, until convergence. From Automatic extraction of multidimensional quantization features: Morphological features include area:
[0099]
[0100] The area above is based on pixel count; perimeter... The contrast is calculated using the boundary pixel chain code; texture features are based on the gray-level co-occurrence matrix (GLCM).
[0101]
[0102] in It is the number of gray levels (usually) ), It is the co-occurrence probability; the contrast feature is defined as the average intensity difference between the defect area and the background:
[0103]
[0104] in This represents the average pixel value. These features provide comprehensive quantitative data and support automated quality grading.
[0105] Step 4: Automatic Quality Grading Based on Multi-Feature Fusion: Multiple extracted defect features are input into a grading decision module. This module can be a classifier or rule engine, which analyzes the influence weights of feature combinations (such as defect size, type, and location on optical performance) to classify defects into different severity levels. This process can dynamically adjust the grading threshold to adapt to the quality standard requirements of different batches or types of optical components, ultimately outputting a defect distribution map and corresponding quality level label for each component. The specific implementation method of this step is as follows:
[0106] The input is the extracted defect feature vector, including size. (Unit: micrometers), type encoding (e.g., 0 represents a scratch, 1 represents a bubble), position coordinates (Normalized to the [0,1] interval). These features are combined into a feature vector:
[0107]
[0108] Each element represents a defect attribute. The decision module uses a softmax classifier to implement multi-level classification, calculating the probability distribution for each severity level. A weight vector is defined. Corresponding to the k-th level, the weight values are obtained through training on historical data and reflect the influence of features on optical performance; for example... This represents the weight of the size in rank k. The score function is used to calculate this. ,here This is a bias term used to adjust the classification boundary. The probability is output via the softmax function.
[0109]
[0110] Where K is the total number of severity levels (e.g., K=3 corresponds to mild, moderate, and severe). This represents the probability that a defect belongs to level k. This probabilistic processing can effectively integrate multiple features, avoid the hard boundary problem of rule engines, and improve the robustness of hierarchical classification.
[0111] Dynamically adjust the grading threshold To adapt to different quality standards; for example, for a new batch of optical components, the threshold is updated based on the average defect data of that batch. Define the adjustment function:
[0112]
[0113] in It is the average defect score of grade k in the current batch. This is a smoothing coefficient (usually set to 0.7), which ensures a smooth threshold transition and reduces the impact of noise. This mechanism allows the system to automatically adapt to changing quality standards without manual resetting, significantly improving production efficiency and consistency.
[0114] Severity levels are determined based on probability output: the level corresponding to the highest probability is selected as the final label, i.e. Simultaneously, a defect distribution map is generated for each component, and image processing libraries (such as OpenCV) are used to visualize the defect locations and levels on the component coordinate system; for example, different colors are used to mark the levels, and corresponding quality level label CSV files are output. The entire process is implemented in an embedded system, integrating a classifier model (such as scikit-learn's SVM) through Python scripts to ensure real-time processing capabilities. This end-to-end automation reduces subjective errors and helps improve the yield rate of optical components.
[0115] Step 5: System Iterative Optimization and Online Adaptation: The grading results are combined with newly collected, expert-reviewed sample data to form a feedback loop. The system periodically or triggeredly utilizes this new, high-quality labeled data to incrementally learn or fine-tune the adaptive learning model in step (2), optimizing its recognition and segmentation performance. Simultaneously, the grading rules in step (4) are calibrated based on quality feedback from actual production. This step ensures that the system can continuously adapt to new defect patterns and changes in the production environment, achieving continuous performance improvement. The specific implementation method of this step is:
[0116] The system constructs a real-time feedback closed-loop mechanism to integrate the defect classification results output in step (4) with the newly collected sample data. The new sample data needs to be reviewed by experts to ensure the quality of the annotation, including defect location masks and category labels, to form a high-quality dataset.
[0117]
[0118] in Indicates the input image. This represents the corresponding annotation mask. This refers to the number of newly added samples. The system uses a monitoring module to detect data accumulation or performance indicators, such as when... ( (For a preset threshold, such as 100 samples) or validation set segmentation accuracy The decline exceeded (like Updates are triggered when needed, enabling periodic (e.g., daily) or event-driven adaptation. This triggering mechanism avoids unnecessary computational overhead and improves system response efficiency.
[0119] Incremental learning is performed on the adaptive learning model from step (2), and the model weights are optimized using an online stochastic gradient descent algorithm. The model weight update formula is as follows: ,in This is the weight vector for the current iteration. The dynamic learning rate (initial value set to) ), The loss function for the segmentation task is defined as the Dice loss:
[0120]
[0121] The predicted probability output by the model. The true mask label. Incremental learning only occurs on new data. Iterative training, rather than full retraining, significantly reduces training time and keeps the model lightweight, enabling the system to quickly adapt to new defect patterns such as unknown cracks or stains. After training, model performance is validated using the IoU metric, ensuring an improvement of at least 2% in recognition and segmentation accuracy.
[0122] Meanwhile, based on quality feedback from actual production (such as user-reported misclassification rates) The grading rules in step (4) are calibrated. The grading rules involve threshold parameters. This is used for defect severity classification. The calibration formula is:
[0123]
[0124] in The original threshold, For feedback deviation ( (Target false positive rate, such as 0.01). A threshold calibration rate factor (preferably 0.1) is used specifically for the feedback closed loop. During calibration, the system analyzes the feedback data distribution and dynamically adjusts... To balance sensitivity and specificity, this closed-loop calibration ensures that grading rules align with production needs. For example, when environmental changes cause variations in defect size, threshold optimization reduces overly strict or lenient grading, improving product quality control consistency. The entire process logs the iteration history, supports performance auditing, and enables continuous system optimization and robustness enhancement.
[0125] Based on the same inventive concept, this invention also provides a computer device, comprising: one or more processors, and a memory for storing one or more computer programs; the programs include program instructions, and the processor executes the program instructions stored in the memory. The processor may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. It is the computing and control core of the terminal, used to implement one or more instructions, specifically for loading and executing one or more instructions stored in a computer storage medium to implement the above-described method.
[0126] It should be further explained that, based on the same inventive concept, the present invention also provides a computer storage medium storing a computer program, which, when executed by a processor, performs the above-described method. This storage medium can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0127] It should be noted that, unless otherwise defined, the technical or scientific terms used in this invention should have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0128] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.
[0129] This invention is not limited to the preferred embodiment described above. Anyone inspired by this invention can derive other various forms of optical element defect identification and grading methods based on few-sample learning and fine segmentation. All equivalent variations and modifications made within the scope of the claims of this invention shall fall within the scope of this invention.
Claims
1. A method for identifying and classifying defects in optical components based on few-sample learning and fine segmentation, characterized in that, Includes the following steps: Images of the surface of precision optical components are acquired from multiple angles and under multiple lighting conditions, and then standardized preprocessing is performed to obtain standardized input images. Construct a deep neural network model based on meta-learning or transfer learning framework, using a small number of labeled precision optical component defect samples and a large number of unlabeled or general defect samples, and train the model through a two-stage strategy that combines inner loop meta-training and outer loop domain adaptation. The inner loop training simulates rapid parameter adaptation for new defect categories, while the outer loop adaptive aligns the feature distributions of the source and target domains through maximum mean difference loss. The model is trained by inputting a standardized input image to obtain the preliminary defect localization result. A cascaded fine segmentation network is used to perform pixel-level iterative refinement of the preliminary localization region. The cascaded fine segmentation network introduces a spatial attention mechanism and an edge perception module, and integrates low-level detail features and high-level semantic features to enhance the boundary segmentation accuracy. It is trained using a composite loss function of Dice loss and edge perception loss to generate a fine defect segmentation mask. The morphological, texture, and contrast multidimensional quantitative features are extracted from the defect fine segmentation mask and input into the grading decision module. Combining the impact weight of defects on optical performance with the dynamic grading threshold based on the combination of smoothing coefficient and batch data statistics, the severity level of defects is classified and the defect distribution map and quality level label are output.
2. The optical element defect identification and grading method based on few-sample learning and fine segmentation according to claim 1, characterized in that: The standardized preprocessing sequentially employs Gaussian filtering for noise reduction, contrast-limited adaptive histogram equalization enhancement, and radial distortion correction, combined with multi-angle and multi-illumination acquisition, to jointly eliminate imaging interference and highlight low-contrast defect characteristics.
3. The optical element defect identification and grading method based on few-sample learning and fine segmentation according to claim 1, characterized in that: The training data is divided into a support set containing a small number of labeled target domain samples and a query set containing a large number of unlabeled / general domain samples. The inner loop meta-training simulates the single-step fine-tuning process for new defect categories through gradient updates, while the outer loop domain adaptation minimizes the maximum mean difference between the source domain and target domain features, thereby achieving the model's rapid adaptability and cross-domain generalization ability.
4. The optical element defect identification and grading method based on few-sample learning and fine segmentation according to claim 1, characterized in that: The cascaded fine segmentation network adopts a two-level structure. The first level outputs a preliminary defect localization probability map and binarizes it into a candidate region mask. The second level focuses on the defect boundary region through a spatial attention mechanism, extracts edge features in combination with the edge perception module, and uses a composite loss function weighted by Dice loss and edge perception loss for end-to-end training.
5. The optical element defect identification and grading method based on few-sample learning and fine segmentation according to claim 1, characterized in that: The morphological features include the defect area and perimeter, the texture features are calculated based on the gray-level co-occurrence matrix, and the contrast features are the average pixel value difference between the defect area and the background area.
6. The optical element defect identification and grading method based on few-sample learning and fine segmentation according to claim 1, characterized in that: The hierarchical decision-making module uses a softmax classifier that integrates multiple features. It trains on historical data to obtain the weights of different defect features on optical performance. The hierarchical threshold is dynamically updated by combining the smoothing coefficient with the mean of the current batch of defect data to adapt to the quality standards of different batches of components.
7. The optical element defect identification and grading method based on few-sample learning and fine segmentation according to claim 1, characterized in that: The method further includes the following steps: constructing a feedback loop between the grading results and the newly collected sample data reviewed by experts; when the number of newly labeled samples reaches a preset threshold or the segmentation accuracy of the model validation set decreases by more than a set amount, the online stochastic gradient descent algorithm is used to update the model weights only on the newly added samples, without the need for full retraining; at the same time, the grading threshold is adaptively calibrated based on the misjudgment rate deviation of the production quality feedback.
8. The optical element defect identification and grading method based on few-sample learning and fine segmentation according to claim 1, characterized in that: The model initialization uses pre-trained weights from the ImageNet dataset to introduce general visual knowledge; random rotation and cropping are used to augment the data of the query set samples to improve sample diversity. An early stopping mechanism is set up during the training process to prevent overfitting.
9. The optical element defect identification and grading method based on few-sample learning and fine segmentation according to claim 1, characterized in that: The cascaded fine segmentation network iterates and refines the initial localization results multiple times, gradually converging to a high-precision defect segmentation mask; during each iteration, the initial localization results are updated and features are extracted and segmented again.
10. An optical element defect identification and grading system for implementing the method of any one of claims 1-9, characterized in that, include: The image acquisition and preprocessing unit is used to perform multi-angle, multi-light image acquisition and standardization preprocessing. The few-shot model training unit is used to perform two-stage few-shot adaptive model training. The defect fine segmentation unit is used to perform cascaded defect region pixel-level fine-tuning and mask generation; The multi-feature fusion hierarchical unit is used to perform multi-dimensional feature extraction and dynamic threshold quality grading.