A numerical control precision part surface defect detection system based on multi-class unsupervised learning
Patent Information
- Application Number
- CN202511662269.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-13
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2045-11-13
AI Technical Summary
[0003]针对现有数控精密零件表面缺陷检测中多类别缺陷难以准确识别、检测效率低下、历史数据管理不完善以及生产工艺反馈机制缺乏联动等问题,本发明提出了一种基于多类别无监督学习的数控精密零件表面缺陷检测系统,用于实现对复杂缺陷的高精度识别、提升检测效率、支持检测数据存储与复检,并将检测结果智能反馈至生产工艺,实现工艺优化和零件质量提升
[0029]实现高精度缺陷识别:本系统通过基于多类别无监督学习的检测方法,实现对裂纹、划痕、凹坑、气孔等复杂缺陷的识别与定位,提高了零件表面缺陷识别的准确性。
Smart Images

Figure CN121582159B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of intelligent inspection and industrial artificial intelligence, and in particular to a surface defect detection system for CNC precision parts based on multi-class unsupervised learning. This system aims to solve problems such as the diverse types of surface defects in CNC machining, low efficiency of manual inspection, and poor adaptability of traditional inspection methods to complex defects, achieving efficient, accurate, and intelligent identification and classification of surface defects in precision parts. Background Technology
[0002] In the machining of CNC precision parts, surface defects directly affect machining quality and assembly accuracy. Traditional manual inspection methods are inefficient, and the results are highly dependent on the operator's experience and skill level, exhibiting significant subjectivity and inconsistency, making it difficult to meet the high-precision surface quality control requirements of high-speed machining lines. Existing automated inspection methods mostly rely on single-category defect identification or simple image feature matching, lacking adaptability to multi-category and complex-shaped defects, and struggling to accurately identify minute cracks, scratches, pits, porosity, and other diverse defects. In the CNC machining environment, the types of surface defects are numerous and unevenly distributed, with high uncertainty in defect size, shape, and location. The machined surface is often affected by factors such as ambient lighting, reflection, and texture, making it difficult for traditional inspection methods to achieve high-precision, real-time defect identification. Furthermore, existing methods lack robustness when handling defect identification under different part materials, batches, and various machining conditions, resulting in low stability of inspection results. This fails to meet the dual demands of modern high-speed machining lines for both inspection efficiency and accuracy, and also makes it difficult to provide reliable data support for part quality control and production decisions. This patent proposes a detection system based on multi-class unsupervised learning for the detection of surface defects in CNC precision parts. Through the end-to-end training and real-time data update mechanism of the unsupervised learning anomaly detection model, it can achieve high-precision, real-time identification and classification of various complex defects, thereby improving the automation level, identification accuracy and overall production efficiency of the production line for the detection of surface defects in parts. Summary of the Invention
[0003] To address the problems of inaccurate identification of multiple types of defects, low detection efficiency, imperfect historical data management, and lack of linkage with production process feedback mechanisms in the existing surface defect detection of CNC precision parts, this invention proposes a surface defect detection system for CNC precision parts based on multi-class unsupervised learning. This system enables high-precision identification of complex defects, improves detection efficiency, supports data storage and re-inspection of detection data, and intelligently feeds the detection results back to the production process, thereby optimizing the process and improving the quality of parts.
[0004] This invention adopts the following technical solution: a surface defect detection system for CNC precision parts based on multi-class unsupervised learning, comprising the following steps:
[0005] The real-time defect detection module is used to acquire surface images of parts using an industrial camera, extract surface features through a ViT-based reconstructive unsupervised model, and obtain defect detection results for the part images.
[0006] The model training and optimization module is used to train and optimize the ViT-based reconstructive unsupervised model by managing part image data, and to automatically adjust and update the model, synchronizing it to the production line for real-time production line detection.
[0007] The inspection data management module is used to achieve unified storage, management and retrieval of part images and part image defect inspection results;
[0008] The intelligent feedback module for production processes is used to generate optimized process parameters based on the defect detection results of part images and send them to the production line, while monitoring the status of the production line to achieve closed-loop control.
[0009] The real-time defect detection module includes:
[0010] The multi-category defect recognition module takes the surface image of the part captured by the industrial camera as input, adopts the ViT-based reconstruction unsupervised model, extracts multi-scale semantic features through the encoder, and generates defect category determination results including reconstruction error map, depth feature map and confidence-based characterization.
[0011] The abnormal region localization module generates an abnormal heatmap by calculating the pixel difference between the reconstruction error map and the depth feature map, and integrates multi-layer semantic features to improve spatial resolution. It uses edge detection operators to extract defect boundaries, combines connected component analysis to separate independent abnormal blocks, calculates the minimum bounding rectangle for each defect region to form a defect bounding box and generates an abnormal region mask, thereby realizing the localization of abnormal locations.
[0012] The multi-scale feature fusion module maps the anomaly region mask and defect bounding box onto the feature maps of each layer of ViT for mask weighting. Then, it performs scale alignment on features of different resolutions. High-level features are upsampled through bilinear interpolation or transposed convolution, while low-level features are downsampled through convolution stride or pooling to ensure that all features are consistent in spatial dimension. The aligned multi-layer features are concatenated along the channel dimension and fused through convolution and ReLU activation functions. Then, a channel attention mechanism is added to enhance the response to small defects. The fused feature map is combined with the mask to generate an enhanced defect response mapping, forming a fused feature map with fine-grained perception capabilities.
[0013] The real-time scoring module takes the defect detection results of the part image composed of fused feature map, defect bounding box and defect category label as input, extracts the geometric and morphological features of the abnormal area, and performs weighted scoring based on the confidence of the abnormal type; it classifies the abnormality into levels according to a preset threshold, and triggers an alarm signal when the score exceeds the threshold, thereby generating the corresponding abnormality level judgment and alarm information.
[0014] The model training and optimization module includes:
[0015] The unsupervised model training module is used to train the ViT-based reconstruction unsupervised model using historical and newly acquired part images as samples, obtain the basic detection model, and import the parameters of the basic detection model into the production line detection system.
[0016] The incremental learning module is used to update samples based on image data of new batches of parts or new types of anomalies, update the network parameters of the basic detection model, and automatically synchronize them to the production line to achieve real-time detection on the production line.
[0017] The performance evaluation module is used to quantitatively evaluate the detection performance of the basic detection model based on the actual detection results of the production line, and obtain the evaluation results to provide a basis for subsequent model optimization.
[0018] The optimization module automatically adjusts the base detection model based on performance evaluation results to improve its accuracy and stability. Specifically: First, based on the accuracy and recall of various anomalies and according to predefined rules, the model adjusts the number of feature extraction layers and attention mechanism parameters of the ViT encoder. Simultaneously, based on predefined rules, the learning rate and optimizer parameters are updated according to gradient history and the trend of the loss curve. During training, the module records the gradient norm and loss change rate over several consecutive rounds. When the loss decrease is below a set threshold or oscillations occur in the past few rounds, the learning rate is dynamically reduced using a learning rate decay function. If the gradient variance is greater than a set value or a gradient vanishing trend occurs, the momentum factor and weight decay coefficient of the optimizer are adjusted according to a preset correspondence to maintain training stability and convergence performance. After optimization, accuracy and stability are evaluated using a validation set, and the optimized model is finally generated and deployed to the production line via an update package.
[0019] The detection data management module includes:
[0020] The image and detection result storage module is used to receive the part image paths collected from the production line and the corresponding detection results obtained through the basic detection model, and store them uniformly in the local database.
[0021] The historical data playback module is used to query data by time period or batch based on part images and inspection results in the database, and to replay the inspection process in a visual interface;
[0022] The re-inspection and verification module is used to screen part images marked as abnormal during the inspection process as initial inspection images and trigger the re-inspection process: re-acquire images and confirm the initial inspection images in conjunction with manual verification operations; use image registration to align the re-inspection images with the initial inspection images, update the defect status and reliability information to form re-inspection data, and send it back to the image and inspection result storage module for storage;
[0023] The statistical analysis and reporting module is used to calculate defect distribution, defect rate and batch quality indicators based on data from the image and inspection result storage module, historical data playback module and re-inspection and verification module, and to generate statistical reports and visualization charts.
[0024] The intelligent feedback module for the production process includes:
[0025] The defect type analysis module takes the defect detection results of the part images output by the real-time defect detection module as input, classifies and statistically analyzes the detection results, identifies the number of different types of anomalies and their spatial distribution characteristics to form defect analysis results; and combines production batch information to calculate the quality indicators of each batch and obtain quality reports.
[0026] The process parameter adjustment module receives defect analysis results and quality reports. First, it calls a database containing images and detection results to retrieve the corresponding historical parameters. Then, it uses the historical process parameters to build a machine learning prediction model based on XGBoost to output a quality index representing the yield rate, and uses it as a quality evaluation function in the particle swarm optimization process. The process parameters are combined as particles, and the particle swarm optimization strategy is used to search in the parameter space to obtain the optimized process parameters.
[0027] The critical defect marking module is used to mark and classify the detected defective part images based on the defect detection results of part images and the feedback data from the production line, according to the set quality level threshold.
[0028] The present invention has the following beneficial effects and advantages:
[0029] Achieving high-precision defect identification: This system uses a detection method based on multi-class unsupervised learning to identify and locate complex defects such as cracks, scratches, pits, and pores, thereby improving the accuracy of surface defect identification for parts.
[0030] Improved inspection efficiency: Relying on real-time defect detection and multi-scale feature fusion technology, the system can quickly process a large number of parts on a high-speed processing line, significantly improving inspection efficiency and reducing manual intervention.
[0031] Enhanced model adaptability and robustness: Through model training and optimization and incremental learning, the system can adapt to different part materials, processing techniques and new defect types, ensuring the stability and reliability of detection results.
[0032] Supports production optimization and closed-loop control: Inspection data management and intelligent feedback functions for production processes enable defect data traceability, statistical analysis, and process parameter optimization, assisting in closed-loop control of the production line, improving product quality, and reducing the defect rate.
[0033] Through the above-mentioned technical means, the present invention provides a high-precision, high-efficiency and intelligent surface defect detection solution for CNC precision parts, which can realize the accurate identification and rapid processing of complex defects, adapt to various part materials and processing technology, and meet the actual needs of modern manufacturing production lines for quality control and process optimization. Attached Figure Description
[0034] Figure 1 This is an overall flowchart of the CNC precision parts surface defect detection system based on multi-class unsupervised learning, as described in this invention.
[0035] Figure 2 The present invention relates to a surface defect detection system for CNC precision parts based on multi-class unsupervised learning.
[0036] Overall system structure diagram; Detailed Implementation
[0037] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of the invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0038] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
[0039] The core technical solution of this invention is achieved through functional modular design. The system mainly includes the following modules:
[0040] Real-time Defect Detection Module: This module performs real-time detection and localization of various types of defects on the surface of machined parts, efficiently detecting complex defects such as cracks, scratches, and dents. The module employs a reconstruction-based unsupervised learning method based on Vision Transformer (ViT), combined with multi-scale feature extraction and deep feature fusion techniques to achieve high-precision localization and classification of surface defects. By analyzing reconstruction errors, the system can automatically identify abnormal areas and generate real-time scores based on defect area, morphology, and severity, thereby supporting quality control and dynamic adjustment in high-speed machining production lines.
[0041] Model Training and Optimization Module: This module trains and optimizes the defect detection model using unsupervised learning methods, enabling the system to adapt to different part materials, manufacturing processes, and novel defect types. The module supports end-to-end training, incremental updates, and model performance monitoring, improving detection robustness and accuracy.
[0042] Inspection Data Management Module: This module manages part images and inspection results, supports historical data storage, playback, and re-inspection, enabling traceability and quality control of inspection data. The system can perform historical comparisons and statistical analyses of different batches of parts, providing data support for production optimization.
[0043] Intelligent Feedback Module for Production Process: This module feeds back the detection results to the production line and process control system, enabling process optimization and quality improvement. Based on the type, quantity, and distribution of defects, the system can automatically generate process parameter adjustment suggestions, guiding production equipment to optimize processing paths and parameters, and simultaneously triggering automatic marking of severely defective parts.
[0044] Detailed descriptions of each module:
[0045] Real-time Defect Detection Module: This module includes a multi-category defect identification module, an abnormal area localization module, a multi-scale feature fusion module, and a real-time scoring module. It enables real-time detection and localization of multiple types of defects on the surface of parts. The system generates scores based on defect area, shape, and severity, and triggers alarms for critical defects.
[0046] Model Training and Optimization Module: This module includes an unsupervised model training module, an incremental learning module, a performance evaluation module, and an optimization module. It trains and optimizes the detection model through unsupervised learning to adapt to different part materials and novel defects. The system supports incremental updates and dynamic adjustment of model parameters to improve detection performance.
[0047] Inspection Data Management Module: This module includes an image and inspection result storage module, a historical data playback module, a re-inspection and verification module, and a statistical analysis and reporting module. It is responsible for storing, playing back, and re-inspecting part images and inspection results. It can perform statistical analysis on data from different batches to support production optimization.
[0048] Intelligent Feedback Module for Production Processes: This module includes a defect type analysis module, a process parameter adjustment module, a production line feedback module, and a critical defect marking module. It feeds defect detection results back to the production line in real time, enabling process parameter optimization. The system marks critical defective parts to aid in closed-loop quality control.
[0049] In this embodiment, a surface defect detection system for CNC precision parts based on multi-class unsupervised learning mainly includes the following four modules: a real-time defect detection module, a model training and optimization module, a detection data management module, and a production process intelligent feedback module. For example... Figure 1 , Figure 2 As shown.
[0050] The real-time defect detection module is deployed on a high-speed machining production line. It acquires images of the part surface through industrial cameras or line scan cameras, and combines hardware acceleration and a high-efficiency image processing pipeline to achieve real-time processing of the entire process from image acquisition and preprocessing to defect detection.
[0051] Multi-category defect recognition module: This module uses an industrial camera to capture images of part surfaces. Surface features are extracted using a VisionTransformer (ViT)-based reconstruction-based unsupervised algorithm to automatically identify defects such as cracks, scratches, and dents, supporting multi-frame image processing per second. Using the part surface images captured by the industrial camera as input, the VisionTransformer (ViT)-based reconstruction-based unsupervised algorithm performs patch segmentation and encoding on the images. The encoder extracts multi-scale semantic features. The decoder reconstructs normal sample features and calculates the difference between the input and reconstructed feature maps, enabling automatic identification of multiple categories of defects such as cracks, scratches, and dents. The module generates detection results including a reconstruction error map, a depth feature map, and preliminary defect category labels.
[0052] Anomaly region localization module: By calculating the reconstruction error map and depth feature map, edge detection and connected component analysis methods are used to accurately label the defect location and generate defect bounding boxes for subsequent scoring. Based on the reconstruction error map and depth feature map output from the recognition stage, an anomaly heatmap is generated by calculating the pixel difference between the two, and multi-layer semantic features are fused to improve spatial resolution. Edge detection operators are used to extract defect boundaries, and connected component analysis is combined to separate independent anomaly blocks. The minimum bounding rectangle is calculated for each defect region to form a bounding box and generate an anomaly region mask, thereby achieving anomaly location localization. Multi-layer semantic features are derived from the ViT encoder, and then upsampled and aligned layer by layer with the anomaly heatmap before weighted fusion to obtain the anomaly response map.
[0053] The multi-scale feature fusion module extracts local and global features at different resolutions and achieves fine-grained detection through a feature pyramid fusion strategy, enhancing sensitivity to minute defects. Using the defect mask and bounding box obtained from the anomaly region localization module as spatial constraints, and combining the semantic feature maps output from each layer of ViT, it extracts local details and global semantic information in a multi-resolution space. In implementation, the defect mask and bounding box are mapped onto feature maps of each layer for mask weighting. Then, the features at different resolutions are scale-aligned. High-level features are upsampled through bilinear interpolation or transposed convolution, while low-level features are downsampled through convolution stride or pooling, ensuring consistency in spatial dimensions across all features. The aligned multi-layer features are concatenated along the channel dimension and fused using convolution and ReLU activation functions. A channel attention mechanism is then added to enhance the response to minute defects. The fused feature map is combined with the mask to generate an enhanced defect response map, forming a fused feature map with fine-grained perception capabilities.
[0054] Real-time scoring module: Calculates scores based on defect area, shape, and severity, and triggers production line alarms via PLC interface, supporting immediate process adjustments. Using fused feature maps, defect bounding boxes, and defect category labels as input, the module comprehensively extracts the geometric and morphological features of abnormal areas and performs weighted scoring based on abnormality type confidence. The module classifies abnormalities into levels according to preset thresholds. When a score exceeds the threshold, an alarm signal is triggered via PLC interface, generating corresponding abnormality level judgment and alarm information. The abnormality type confidence comes from the multi-category defect recognition module; the confidence scores of multiple categories are weighted and summed according to predefined weights to obtain a comprehensive score for each abnormal area.
[0055] The model training and optimization module connects to the workshop server and the production line acquisition system to centrally manage part image data, enabling periodic training and optimization of the model. This module can automatically adjust the model strategy based on different materials, sizes, and processing conditions, ensuring the accuracy and robustness of the detection model in actual production. The system supports offline training and online fine-tuning, and can automatically generate update packages and distribute them to the production line, achieving continuous model adaptation and performance improvement while balancing computational resources and training efficiency.
[0056] Unsupervised model training module: This module trains the model using historical and newly acquired part images from a server, extracting features through an unsupervised learning method based on the ViT architecture. Images are first normalized and data augmented, then input into the ViT encoder to extract multi-scale features. A decoder then reconstructs normal sample features, with the network optimization objective being to minimize reconstruction error. After training, the module generates a basic detection model and imports the model parameters into the production line inspection system.
[0057] Incremental Learning Module: This module is designed for small batches of images of new parts or novel anomalies, using existing basic detection models. It updates some network parameters of the basic model through small-batch online fine-tuning while maintaining the original detection capabilities. The updated, incrementally optimized detection model is automatically synchronized to the production line for real-time detection.
[0058] Performance Evaluation Module: Based on actual production line inspection results, this module quantitatively evaluates the model's detection performance. It calculates metrics such as accuracy, recall, and F1-score, and can analyze different anomaly types and sizes. During execution, the detection results are compared with reference standards, generating statistical reports and visualization curves to provide a basis for subsequent model optimization. The output is a detailed performance evaluation report, including the values of each metric and performance analysis for each anomaly type.
[0059] The optimization module automatically adjusts the model structure, learning rate, feature fusion strategy, and other hyperparameters based on performance evaluation results. It analyzes model bottlenecks by assessing accuracy and recall for various anomalies, adjusting the number of feature extraction layers and attention mechanism in the ViT encoder to effectively utilize both local and global features. The learning rate and optimizer parameters are updated using gradient history and loss curves to accelerate convergence and prevent overfitting. After optimization, the module evaluates accuracy and stability on a mini-batch validation set, ultimately generating the optimized model and deploying it to the production line via an update package.
[0060] The inspection data management module establishes a data control channel between the production line and the back-end server, enabling unified storage, management, and retrieval of part images and inspection results. The module can automatically classify and index data according to batch, time, and process parameters, supporting rapid querying and historical traceability. The system provides interfaces to connect inspection data with the production management system, enabling real-time statistics, trend analysis, and quality report generation. This provides data support for production optimization, anomaly tracking, and decision-making, while ensuring data security and access control management.
[0061] Image and Inspection Result Storage Module: This module receives part image paths and corresponding anomaly detection results collected from the production line and stores the data uniformly in a local database. Images and inspection results are batch-marked and timestamped before storage, and the database automatically creates an index to support fast retrieval. The module uses a relational database to manage structured data and performs archiving operations to ensure that historical data can be accessed long-term and supports subsequent analysis and playback modules.
[0062] Historical data playback module: Based on the part images and inspection results organized by the storage module, specific data can be queried by time period or batch, and the inspection process can be replayed in a visualization interface built on Echarts. The system automatically compares the playback data with the previous defect inspection results, generating defect change trend curves and statistical charts, providing intuitive basis for production optimization and process adjustment.
[0063] Re-inspection and Verification Module: During the inspection process, parts marked as abnormal are automatically selected by this module, triggering a re-inspection process. The re-inspection re-captures images using a high-definition industrial camera and combines this with manual verification to confirm the initial inspection results. The system uses image registration to align the re-inspection results with the initial inspection data and updates defect status and reliability information to ensure the accuracy of abnormal part identification. Simultaneously, the re-inspection data is sent back to the storage module, forming a complete data loop.
[0064] Statistical Analysis and Reporting Module: Based on data from the storage module, historical playback module, and re-inspection module, this module automatically calculates defect distribution, defect rate, and batch quality indicators, generating statistical reports and visualization charts. Through batch aggregation, grouped statistics, and trend analysis algorithms, the module comprehensively analyzes real-time and historical data, providing a basis for production line quality control and management decisions.
[0065] The intelligent feedback module for production processes uses real-time data interfaces with the production line control system and processing equipment to apply defect detection results to automated decision-making and process optimization, achieving closed-loop control. The module can generate batch quality assessments and instructions for adjusting processing parameters based on detection data, and supports the rapid identification and tracking of critical defective parts. The system ensures data synchronization with the ME system for quality management and production optimization.
[0066] Defect Type Analysis Module: Taking the defect detection results of the part images output by the detection module as input, the module classifies and statistically analyzes the detection results, identifying the quantity and spatial distribution characteristics of different types of anomalies. Then, combining this with production batch information, it calculates the quality indicators for each batch. The analysis results are displayed through a visual interface and generated into structured reports stored in the database, providing a basis for subsequent process parameter adjustments.
[0067] The process parameter adjustment module receives defect analysis results and quality reports. First, it calls a database containing images and detection results to retrieve the corresponding historical parameters. Then, it uses the historical process parameters to build a machine learning prediction model based on XGBoost to output a quality index representing the yield rate, which is used as the quality evaluation function in the particle swarm optimization process. The process parameters are combined as particles, and the particle swarm optimization strategy is used to search in the parameter space to obtain the optimized process parameters.
[0068] Production line feedback module: Receives optimized parameters from the process parameter adjustment module and sends them to the corresponding processing equipment control terminal. The module simultaneously monitors the parameter execution status and equipment response to ensure the adjustment plan takes effect promptly. When necessary, operators can manually confirm and update the suggested parameters on the monitoring terminal, achieving coordinated control of automation and manual intervention.
[0069] Critical Defect Marking Module: Taking defect detection results and production line feedback data as input, the module automatically marks and classifies critically defective parts according to the system's set quality level thresholds. The marking information is stored in association with the part number, batch number, and process adjustment records for easy rework, traceability, or statistical analysis.
[0070] Through specific implementations of this invention, the accuracy and efficiency of surface defect detection for CNC precision parts can be significantly improved, ensuring the quality stability of high-speed machining lines. By employing real-time detection through multi-category unsupervised learning, model optimization, and closed-loop feedback in the production process, this system achieves high-precision identification, rapid response, and data traceability of part defects. It possesses strong engineering feasibility and scalability, and is suitable for various part materials and complex machining environments.
[0071] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications should be considered within the scope of protection of the present invention.
Claims
1. A surface defect detection system for CNC precision parts based on multi-class unsupervised learning, characterized in that, Includes the following steps: The real-time defect detection module is used to acquire surface images of parts using an industrial camera, extract surface features through a ViT-based reconstructive unsupervised model, and obtain defect detection results for the part images. The model training and optimization module is used to train and optimize the ViT-based reconstructive unsupervised model by managing part image data, and to automatically adjust and update the model, synchronizing it to the production line for real-time production line detection. The inspection data management module is used to achieve unified storage, management and retrieval of part images and part image defect inspection results; The intelligent feedback module for production process is used to generate optimized process parameters based on the defect detection results of part images and send them to the production line, while monitoring the status of the production line to achieve closed-loop control. The real-time defect detection module includes: The multi-category defect recognition module takes the surface image of the part captured by the industrial camera as input, adopts the ViT-based reconstruction unsupervised model, extracts multi-scale semantic features through the encoder, and generates defect category determination results including reconstruction error map, depth feature map and confidence-based characterization. The abnormal region localization module generates an abnormal heatmap by calculating the pixel difference between the reconstruction error map and the depth feature map, and integrates multi-layer semantic features to improve spatial resolution. It uses edge detection operators to extract defect boundaries, combines connected component analysis to separate independent abnormal blocks, calculates the minimum bounding rectangle for each defect region to form a defect bounding box and generates an abnormal region mask, thereby realizing the localization of abnormal locations. The multi-scale feature fusion module maps the anomaly region mask and defect bounding box onto the feature maps of each layer of ViT for mask weighting. Then, it performs scale alignment on features of different resolutions. High-level features are upsampled through bilinear interpolation or transposed convolution, while low-level features are downsampled through convolution stride or pooling to ensure that all features are consistent in spatial dimension. The aligned multi-layer features are concatenated along the channel dimension and fused through convolution and ReLU activation functions. Then, a channel attention mechanism is added to enhance the response to small defects. The fused feature map is combined with the mask to generate an enhanced defect response mapping, forming a fused feature map with fine-grained perception capabilities. The real-time scoring module takes the defect detection results of the part image composed of fused feature map, defect bounding box and defect category label as input, extracts the geometric and morphological features of the abnormal area, and performs weighted scoring based on the confidence of the abnormal type; it classifies the abnormality into levels according to a preset threshold, and triggers an alarm signal when the score exceeds the threshold, thereby generating the corresponding abnormality level judgment and alarm information.
2. The surface defect detection system for CNC precision parts based on multi-class unsupervised learning according to claim 1, characterized in that, The model training and optimization module includes: The unsupervised model training module is used to train the ViT-based reconstruction unsupervised model using historical and newly acquired part images as samples, obtain the basic detection model, and import the parameters of the basic detection model into the production line detection system. The incremental learning module is used to update samples based on image data of new batches of parts or new types of anomalies, update the network parameters of the basic detection model, and automatically synchronize them to the production line to achieve real-time detection on the production line. The performance evaluation module is used to quantitatively evaluate the detection performance of the basic detection model based on the actual detection results of the production line, and obtain the evaluation results to provide a basis for subsequent model optimization. The optimization module automatically adjusts the base detection model based on performance evaluation results to improve its accuracy and stability. Specifically: First, based on the accuracy and recall of various anomalies and according to predefined rules, the model adjusts the number of feature extraction layers and attention mechanism parameters of the ViT encoder. Simultaneously, based on predefined rules, the learning rate and optimizer parameters are updated according to gradient history and the trend of the loss curve. During training, the module records the gradient norm and loss change rate over several consecutive rounds. When the loss decrease is below a set threshold or oscillations occur in the past few rounds, the learning rate is dynamically reduced using a learning rate decay function. If the gradient variance is greater than a set value or a gradient vanishing trend occurs, the momentum factor and weight decay coefficient of the optimizer are adjusted according to a preset correspondence to maintain training stability and convergence performance. After optimization, accuracy and stability are evaluated using a validation set, and the optimized model is finally generated and deployed to the production line via an update package.
3. The surface defect detection system for CNC precision parts based on multi-class unsupervised learning according to claim 1, characterized in that, The detection data management module includes: The image and detection result storage module is used to receive the part image paths collected from the production line and the corresponding detection results obtained through the basic detection model, and store them uniformly in the local database. The historical data playback module is used to query data by time period or batch based on part images and inspection results in the database, and to replay the inspection process in a visual interface; The re-inspection and verification module is used to screen part images marked as abnormal during the inspection process as initial inspection images and trigger the re-inspection process: re-acquire images and confirm the initial inspection images in conjunction with manual verification operations; use image registration to align the re-inspection images with the initial inspection images, update the defect status and reliability information to form re-inspection data, and send it back to the image and inspection result storage module for storage; The statistical analysis and reporting module is used to calculate defect distribution, defect rate and batch quality indicators based on data from the image and inspection result storage module, historical data playback module and re-inspection and verification module, and to generate statistical reports and visualization charts.
4. The surface defect detection system for CNC precision parts based on multi-class unsupervised learning according to claim 1, characterized in that, The intelligent feedback module for the production process includes: The defect type analysis module takes the defect detection results of the part images output by the real-time defect detection module as input, classifies and statistically analyzes the detection results, identifies the number of different types of anomalies and their spatial distribution characteristics to form defect analysis results; and combines production batch information to calculate the quality indicators of each batch and obtain quality reports. The process parameter adjustment module receives defect analysis results and quality reports. First, it calls a database containing images and detection results to retrieve the corresponding historical parameters. Then, it uses the historical process parameters to build a machine learning prediction model based on XGBoost to output a quality index representing the yield rate, and uses it as a quality evaluation function in the particle swarm optimization process. The process parameters are combined as particles, and the particle swarm optimization strategy is used to search in the parameter space to obtain the optimized process parameters. The critical defect marking module is used to mark and classify the detected defective part images based on the defect detection results of part images and the feedback data from the production line, according to the set quality level threshold.
Citation Information
Patent Citations
ViT-based unsupervised gray fabric defect detection method, system, equipment and medium
CN116503329A
Unsupervised accurate anomaly positioning and segmentation method and system
CN118864856A