Automobile part surface flaw and defect detection method and system based on feature heterogeneity measurement
Patent Information
- Application Number
- CN202611049795.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-15
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2046-07-15
AI Technical Summary
然而,现有异常检测方法仍面临巨大的局限性:通常将所有非理想状态视为异常,无法根据严重程度对瑕疵和缺陷进行区分,这种 “一刀切” 的做法不仅降低了检测结果的实用性,还可能导致不必要的资源浪费,增加复检工人的工作强度,极大地影响生产质量与效率;此外,模型的内存占用和参数规模较大,限制了其在资源受限的工业环境中的应用,较大的模型参数会增加检测的节拍时间,降低检测与生产效率
[0017]上述一种基于特征异质性度量的汽车零部件表面瑕疵与缺陷检测方法及系统,基于线性相似性与非线性独立性两个维度计算异质性度量值,并选择性地将瑕疵样本特征更新至特征记忆池,使得记忆池中保留了能够区分瑕疵与缺陷的异质特征,从而在检测阶段能够根据异常分数精准识别正常区域、瑕疵区域与缺陷区域,克服了现有技术将所有非理想状态统一视为异常而无法区分瑕疵与缺陷的缺陷;同时,通过对更新后的特征记忆池执行同质特征自蒸馏,剔除冗余的同质化特征,得到精简后的特征记忆池,显著减少了模型部署时的内存占用与推理时间,使其能够适配资源受限的工业生产线,满足实时性要求。此外,在应用阶段采用与训练阶段相同的特征提取器提取测试特征,并与精简后的特征记忆池中的基准特征进行对比计算异常分数,进而依据阈值进行分类判断,该机制确保了检测的准确性和鲁棒性。最后,仅需无缺陷正常样本和轻微瑕疵样本即可完成模型训练,无需大量标注的缺陷样本,基于无监督或半监督学习模式能够适应汽车制造生产线的动态环境变化,具有良好的泛化能力和工业实用性。
Smart Images

Figure CN122550607B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of quality inspection technology in the automotive manufacturing industry, and in particular relates to a method and system for detecting surface defects and flaws in automotive parts based on characteristic heterogeneity measurement. Background Technology
[0002] In the automotive manufacturing industry, the quality of components directly affects the safety and performance of vehicles. Therefore, accurate detection of surface defects and flaws in automotive components is crucial. Traditional methods for detecting surface defects and flaws mainly rely on manual visual inspection or simple automated inspection systems. While these methods can identify obvious defects to some extent, they often struggle to accurately identify subtle flaws.
[0003] With the rapid development of deep learning, intelligent automotive component defect detection technologies are constantly emerging. Existing deep learning-based surface defect and flaw detection methods are mainly divided into two categories: defect target detection methods and anomaly detection methods. Defect target detection methods are usually based on supervised learning, training models by labeling a large number of defect samples to achieve accurate detection and identification of specific defects. These methods are highly effective in scenarios where the defect type is clear and there is sufficient labeled data. However, the dependence on a large amount of labeled data severely limits their widespread application in industrial scenarios, because obtaining a sufficient quantity and quality of labeled data is often costly and time-consuming.
[0004] Unlike defect detection methods, anomaly detection methods are typically based on unsupervised or semi-supervised learning. They identify anomalies (including flaws and defects) by modeling the feature distribution of normal samples. This eliminates the need for large amounts of labeled defect data, making them more practical in industrial scenarios. In recent years, anomaly detection methods have made significant progress, including reconstruction-based methods, generative adversarial network (GAN)-based methods, feature embedding-based methods, and self-supervised learning-based methods. However, existing anomaly detection methods still face significant limitations: they typically treat all non-ideal states as anomalies, failing to differentiate between flaws and defects based on severity. This "one-size-fits-all" approach not only reduces the practicality of the detection results but may also lead to unnecessary resource waste, increase the workload of re-inspection workers, and significantly impact production quality and efficiency. Furthermore, the large memory footprint and parameter size of the models limit their application in resource-constrained industrial environments. Larger model parameters increase detection cycle time, reducing detection and production efficiency.
[0005] Although attempts were made to retrain the anomaly detection model by adding defective samples to the training dataset, these outliers significantly contaminate the memory pool, severely impacting anomaly detection performance and failing to effectively distinguish between defects and flaws. Therefore, developing a detection method that can accurately differentiate between defects and flaws while also possessing high deployability has become a pressing issue in the field of defect detection in the automotive manufacturing industry. Summary of the Invention
[0006] To address the above technical problems, this invention provides a method and system for detecting surface defects and flaws in automotive parts based on feature heterogeneity measurement.
[0007] The technical solution adopted by this invention to solve its technical problem is: A method for detecting surface defects and flaws in automotive parts based on feature heterogeneity measurement includes the following steps: S100: Obtain defect-free normal automotive parts samples and construct an initial feature memory pool; S200: Obtain samples of automotive parts containing defects, extract features of defective samples through a pre-trained feature extractor, and calculate the heterogeneity measure between the features of defective samples and the features in the initial feature memory pool based on two dimensions: linear similarity and nonlinear independence. Combined with a preset heterogeneity threshold, selectively update the features of defective samples to the initial feature memory pool to form an updated feature memory pool. S300: Perform a homogeneous feature self-distillation process on the updated feature memory pool. By calculating the heterogeneity between feature pairs, redundant homogeneous features are identified and eliminated to obtain a simplified feature memory pool. S400: Acquire surface images of the automotive parts to be inspected, and extract their test features using the same feature extractor as in the training phase; S500: The test features are compared with the baseline features in the simplified feature memory pool to calculate the anomaly score. The test features are then classified and judged according to the preset anomaly score threshold to identify normal areas, flawed areas and defective areas in the image to be detected.
[0008] Preferably, S100 includes: S110: Employs a pre-trained neural network model as the basic feature extractor, and defines the neighborhood size as... The feature aggregation function is used to extract local perceptual features from normal automotive parts samples; S120: Collect the features of all normal samples after local perceptual feature aggregation processing, and construct an initial feature memory pool covering multi-level feature information.
[0009] Preferably, S110 specifically comprises: At each location in the feature map ( h , w Aggregate feature vectors within the neighborhood, neighborhood Defined as: in, For the size of the neighborhood, and These represent the position indices in the height and width directions of the feature map, respectively. and These represent the height and width coordinates of the pixels in the neighborhood, respectively. Location( h , w Local perceptual features at ) for: in, It is an aggregate function. It is a normal sample x i In the network j Location of layer extraction Features of the location; S120 specifically refers to: in, It is a collection of all defect-free, normal automotive parts samples. j These are indices for different levels of a pre-trained neural network. h , w This iterates through all positions on the feature map. This serves as the initial feature memory pool.
[0010] Preferably, S200 includes: S210: Use the same feature extractor as the one used to construct the initial feature memory pool to perform consistent feature extraction on multiple defective samples. The parameter settings of the feature extractor include the neural network model and the neighborhood size. Aggregate functions To obtain the features of each defect sample ; S220: Calculate the characteristics of defective samples With feature memory pool Chinese characteristics cosine similarity s i As a result of linear similarity measurement, specifically: S230: Using stochastic Fourier transform to characterize defective samples and feature memory pool Chinese characteristics The transformation is performed, and the independence between the two is measured using the Hilbert-Schmidt independence criterion. As a measure of nonlinear independence, the specific result is as follows: in This represents the random Fourier transform operation. Represents the Hilbert-Schmidt independence criterion; S240: Calculate Independence Similarity s i The difference between As a measure of heterogeneity, it is specifically: S250: Set heterogeneity threshold t ,like h > t Then the features of the defective samples will be... Add to feature memory pool In the process, the updated feature memory pool is obtained. .
[0011] Preferably, S300 includes: For the updated feature memory pool Each pair of features Calculate its heterogeneity measure. h ij The calculation formula is: in, It is a feature and The results of the independence measurement, It is the cosine similarity between the two; Set a threshold for homogeneous features the ,like h ij < the Then determine the feature and For redundant homogeneous features, and from the feature memory pool By removing one of the features, a simplified feature memory pool containing only non-redundant heterogeneous features is obtained. M' .
[0012] Preferably, the same feature extractor as in the training phase is used in S400 for the test image. Local perceptual feature extraction is performed to obtain the feature set of the test image. .
[0013] Preferably, calculating the anomaly score in S500 includes: For each feature of the test image Calculate its relationship with the simplified feature memory pool. The minimum Euclidean distance among all features is used, and the maximum distance value among all features is taken as the anomaly score. s Specifically: Alternatively, the anomaly score can be optimized using nearest neighbor features. The optimized anomaly score is as follows: in, For test images, For test images The feature set obtained after feature extraction These are the feature vectors in the feature memory pool M'. , indicating that the feature memory pool M' contains and The nearest feature vector, It is a feature memory pool middle The nearest neighbor feature set.
[0014] Preferably, in S500, an anomaly detection threshold is set. The calculated abnormal scores s and Comparison: If If the test image region corresponding to the feature is determined to be a defect region; if If the region is determined to be a normal region or a defective region, then an anomaly segmentation map is generated by upsampling and spatial alignment patch-level scores.
[0015] A system for detecting surface defects and flaws in automotive parts based on feature heterogeneity measurement, comprising the following steps for performing a method for detecting surface defects and flaws in automotive parts based on feature heterogeneity measurement: The initial memory pool construction module is used to obtain defect-free normal automotive parts samples and construct the initial feature memory pool; The memory pool update module is used to obtain automotive parts samples containing defects, extract defect sample features through a pre-trained feature extractor, and calculate the heterogeneity measure between the defect sample features and the features in the initial feature memory pool based on two dimensions: linear similarity and nonlinear independence. Based on the heterogeneity measure, the defect sample features are selectively updated to the initial feature memory pool to form an updated feature memory pool. The homogeneous feature self-distillation module is used to perform a homogeneous feature self-distillation process on the updated feature memory pool. It identifies and removes redundant homogeneous features by calculating the heterogeneity between feature pairs, resulting in a simplified feature memory pool. The test feature extraction module is used to acquire surface images of the automotive parts to be inspected and extract their test features using the same feature extractor as in the training phase. The anomaly detection and classification module compares the test features with the baseline features in the simplified feature memory pool, calculates the anomaly score, and classifies the test features according to the preset anomaly score threshold to identify normal areas, flawed areas, and defective areas in the image to be detected.
[0016] A computer device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of a method for detecting surface defects and flaws in automotive parts based on a feature heterogeneity metric.
[0017] The aforementioned method and system for detecting surface defects and flaws in automotive parts based on feature heterogeneity measurement calculates heterogeneity metrics based on two dimensions: linear similarity and nonlinear independence. It selectively updates the feature memory pool with the features of defect samples, ensuring that the pool retains heterogeneous features that can distinguish between defects and flaws. This allows for accurate identification of normal, defective, and flawed regions based on anomaly scores during the detection phase, overcoming the limitation of existing technologies that uniformly treat all non-ideal states as anomalies and fail to differentiate between defects and flaws. Simultaneously, by performing homogeneous feature self-distillation on the updated feature memory pool, redundant homogeneous features are eliminated, resulting in a simplified feature memory pool. This significantly reduces memory usage and inference time during model deployment, enabling it to adapt to resource-constrained industrial production lines and meet real-time requirements. Furthermore, in the application phase, the same feature extractor as in the training phase is used to extract test features, which are then compared with the baseline features in the simplified feature memory pool to calculate anomaly scores. Classification is then performed based on thresholds, ensuring the accuracy and robustness of the detection. Finally, model training can be completed with only undefected normal samples and slightly flawed samples, without the need for a large number of labeled defective samples. Based on unsupervised or semi-supervised learning mode, it can adapt to the dynamic environmental changes of automobile manufacturing production lines and has good generalization ability and industrial applicability. Attached Figure Description
[0018] Figure 1 This is a flowchart of a method for detecting surface defects and flaws in automotive parts based on feature heterogeneity measurement in one embodiment of the present invention. Figure 2 This is an overall framework diagram of a method for detecting surface defects and flaws in automotive parts based on feature heterogeneity measurement in one embodiment of the present invention. Detailed Implementation
[0019] To enable those skilled in the art to better understand the technical solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings.
[0020] To effectively address the core pain points of existing anomaly detection methods in automotive component surface quality inspection—the inability to accurately distinguish between acceptable minor defects and unacceptable severe defects, as well as the large memory consumption and low inference efficiency during model deployment, making it difficult to adapt to actual industrial production needs—this invention innovatively proposes a feature heterogeneity measurement memory pool distillation (FHM-MPD) method and system for detecting surface defects and flaws in automotive components.
[0021] The core design of this solution revolves around two main objectives: "accurate differentiation" and "efficient deployment." On the one hand, through a feature heterogeneity measurement mechanism, the feature differences between defects and flaws are deeply mined and separated. Heterogeneous features with significant discriminative power are dynamically added to the feature memory pool, enabling the model to accurately identify and mask the response of defective areas during the testing phase, thereby achieving effective separation of minor defects from flaws. On the other hand, a homogeneous feature self-distillation strategy is introduced to selectively remove redundant homogeneous features from the memory pool. While ensuring that the detection accuracy is not affected, the model parameter scale is greatly reduced, memory consumption and inference time are decreased, and the deployment adaptability of the method in resource-constrained industrial scenarios is significantly improved.
[0022] The detection method of this invention is divided into a model training stage and a detection application stage. The two stages are closely linked and synergistically optimized to form a complete closed-loop detection system from model construction to practical application. The specific process is as follows: Model training phase: First, based on samples of defect-free normal automotive parts, an initial feature memory pool covering multi-dimensional and multi-level features is constructed to establish a benchmark for subsequent feature comparison and differentiation. Then, input samples of parts containing minor defects, extract their global and local features using a pre-trained feature extractor, and employ a specially designed heterogeneity measurement feature memory pool update strategy. This strategy comprehensively measures the correlation between defect features and the original normal sample features in the memory pool from two dimensions: linear association (similarity) and non-linear association (independence), accurately filtering out homogeneous features shared by defects and retaining only heterogeneous features with unique distinguishing value, which are then updated into the feature memory pool. Finally, a homogeneous feature self-distillation process is initiated to deeply optimize the updated feature memory pool, eliminating duplicate and redundant homogeneous features, ultimately forming a streamlined and highly efficient feature memory pool with high feature recognition, completing the entire model training process.
[0023] In the detection application stage: the surface image of the automotive parts to be inspected is used as a test sample and input into the trained model. Multi-scale and multi-dimensional feature information of the test image is extracted through the same feature extractor as in the training stage. Then, the extracted test features are compared point by point and layer by layer with the baseline features in the simplified feature memory pool. The anomaly score is obtained by calculating the degree of difference between features. Finally, based on the preset scientific and reasonable anomaly score threshold, each region in the test image is classified and judged to accurately identify normal regions, flawed regions and defective regions, so as to realize the refined detection and classification of the surface quality of automotive parts.
[0024] Overall flowchart as follows Figure 1 As shown in the diagram, the overall framework is as follows: Figure 2 As shown.
[0025] (a) Construction of the initial feature memory pool.
[0026] S100: Obtain defect-free normal automotive parts samples and construct an initial feature memory pool.
[0027] Specifically, the initial feature memory pool is constructed to provide a stable and comprehensive benchmark feature library for subsequent feature comparison and heterogeneity measurement. Its construction process draws on the core ideas of the PatchCore method and is optimized in combination with the special characteristics of automotive parts surface features. The specific steps are as follows: S110: Employs pre-trained neural network models (such as the ResNet series and EfficientNet series) that excel in image recognition as the basic feature extractor. These models are trained on large-scale image datasets and possess powerful feature representation capabilities, effectively capturing multi-dimensional features such as texture, contour, and details of automotive parts. To further enhance the local correlation and discriminability of features, a neighborhood size is defined as... The feature aggregation function is used at each location of the feature map. h , w The feature vectors within the aggregated neighborhood are used to extract local perceptual features from normal automotive component samples; further, S110 specifically involves: At each location in the feature map ( h , w The feature vectors within the aggregated neighborhood are aggregated. Defined as: in, For the size of the neighborhood, and These represent the position indices in the height and width directions of the feature map, respectively. and These represent the height and width coordinates of the pixels in the neighborhood, respectively. The range of this neighborhood can be flexibly adjusted according to the size and surface feature complexity of the automotive parts to ensure that the local feature information of the target area is fully covered. Location( h , w Local perceptual features at ) for: in, It is an aggregation function, preferably an adaptive averaging function, which can effectively reduce noise interference while preserving key feature information. It is a normal sample x i In the network j Location of layer extraction Features at the location; through multi-layer feature extraction, multi-level feature information from low to high level and from local to global can be obtained, laying the foundation for subsequent accurate differentiation.
[0028] S120: Collect the features of all normal samples after local perceptual feature aggregation processing, and construct an initial feature memory pool covering multi-level feature information; further, S120 specifically includes: in, It is a collection of all defect-free, normal automotive parts samples. j These are indices for different levels of a pre-trained neural network. h , w This iterates through all positions on the feature map. This serves as the initial feature memory pool.
[0029] This initial feature memory pool comprehensively covers various feature patterns on the surface of normal automotive parts, providing a complete benchmark reference system for subsequent comparative analysis with flaw and defect features.
[0030] (ii) Feature memory pool update (heterogeneity measurement feature memory pool update strategy) S200: Obtain samples of automotive parts containing defects, extract features of the defect samples through a pre-trained feature extractor, and calculate the heterogeneity measure between the features of the defect samples and the features in the initial feature memory pool based on two dimensions: linear similarity and nonlinear independence. Combined with a preset heterogeneity threshold, selectively update the features of the defect samples to the initial feature memory pool to form an updated feature memory pool.
[0031] To enable the model to accurately capture the essential differences between flaws and defects, after the initial feature memory pool is constructed, flaw samples need to be introduced to dynamically update the memory pool. A heterogeneity measurement mechanism is then used to filter out feature information with discriminative value. The specific implementation process is as follows: S210: Use the same feature extractor as the one used to construct the initial feature memory pool to perform consistent feature extraction on multiple defective samples. The parameter settings of the feature extractor include the neural network model and the neighborhood size. Aggregate functions To obtain the features of each defect sample ; Ensure that the extracted defective sample features (denoted as Features have the same dimensions, scale, and representation logic as those in the initial memory pool, avoiding comparison bias caused by inconsistent feature extraction methods; S220: Calculate the characteristics of defective samples With feature memory pool Chinese characteristics cosine similarity s i As a result of linear similarity measurement, specifically: The cosine similarity value ranges from [-1, 1]. The closer the value is to 1, the higher the linear similarity between the two features; the closer the value is to -1, the greater the linear difference between the two features. This index can effectively measure the degree of linear correlation between defective features and normal features.
[0032] S230: Using stochastic Fourier transform to characterize defective samples and feature memory pool Chinese characteristics The transformation is performed, and the independence between the two is measured using the Hilbert-Schmidt independence criterion. As a measure of nonlinear independence, the specific result is as follows: in This represents the random Fourier transform operation. The HSIC value represents the Hilbert-Schmidt independence criterion; the larger the HSIC value, the stronger the independence between the two and the more significant the nonlinear difference; conversely, the smaller the HSIC value, the higher the degree of nonlinear correlation between the two.
[0033] S240: Calculate Independence Similarity s i The difference between As a measure of heterogeneity, it is specifically: The difference It can simultaneously take into account the feature differences in both linear similarity and nonlinear independence, when A large value indicates that defective features and normal features exhibit significant heterogeneity overall, making them valuable for inclusion in the memory pool to aid in distinguishing between defects and flaws; when When the value is small, it indicates that the difference between defective features and normal features is not significant. If it is included in the memory pool, it may interfere with subsequent detection and judgment.
[0034] S250: Set heterogeneity threshold t ,like h > t This indicates the characteristics of the defective sample. If there are significantly heterogeneous features with the features in the feature memory pool, then the flawed sample features will be... Add to feature memory pool In the process, the updated feature memory pool is obtained. This step eliminates the homogeneous characteristics of defects and flaws while preserving their heterogeneous characteristics, enabling the anomaly detection method to effectively distinguish between defects and flaws.
[0035] (iii) Homogeneous characteristics of self-distillation S300: Perform a homogeneous feature self-distillation process on the updated feature memory pool. By calculating the heterogeneity between feature pairs, redundant homogeneous features are identified and eliminated to obtain a simplified feature memory pool.
[0036] Updated feature memory pool While containing the key heterogeneous features needed to distinguish between flaws and defects, some repetitive and redundant homogeneous features may still exist. These features increase the model's memory footprint, prolong inference time, and affect the model's deployment efficiency in industrial scenarios. Therefore, this invention designs a homogeneous feature self-distillation strategy to address this issue. Further optimizations are performed to achieve efficient and streamlined feature memory pooling. The specific process is as follows: S310: For the updated feature memory pool Each pair of features Calculate its heterogeneity measure. h ij The heterogeneity calculation method here is consistent with the heterogeneity measurement logic in the feature memory pool update stage, while taking into account both linear similarity and nonlinear independence. The calculation formula is as follows: in, It is a feature and The results of the independence measurement, This is the cosine similarity between the two, i.e., the linear similarity result. It is calculated using this formula. It can accurately reflect the degree of heterogeneity between a pair of features; S320: Set the threshold for homogeneous features the ,like h ij < the Then determine the feature and These are redundant homogeneous features, indicating redundancy, and are retrieved from the feature memory pool. After removing one feature from the pool, the final result is a simplified feature memory pool containing only non-redundant heterogeneous features, following the steps described above. M' Complete model training.
[0037] (iv) Application phase S400: Acquire surface images of the automotive parts to be inspected, and extract their test features using the same feature extractor as in the training phase.
[0038] Specifically, S400 uses the same feature extractor as the training phase for the test images. Local perceptual feature extraction is performed to obtain the feature set of the test image. The surface image of the automotive component to be inspected is used as the test image. The data is then input into the trained detection model. A feature extractor identical to that used in the model training phase is employed to perform multi-scale, multi-dimensional local perceptual feature extraction on the test images, ensuring that the extracted test features match the simplified feature memory pool. M' The features in the dataset have a consistent representation format and dimensionality, avoiding detection errors caused by feature mismatch. This ultimately yields a complete feature set for the test image. This set covers key feature information of all areas on the surface of the test image, providing data support for subsequent anomaly detection.
[0039] (v) Calculation of outlier scores S500: The test features are compared with the baseline features in the simplified feature memory pool to calculate the anomaly score. The test features are then classified and judged according to the preset anomaly score threshold to identify normal areas, flawed areas and defective areas in the image to be detected.
[0040] (vi) Threshold determination and result output The calculation of outlier scores in S500 includes: For each feature of the test image Calculate its relationship with the simplified feature memory pool. The minimum Euclidean distance among all features is used, and the maximum distance value among all features is taken as the anomaly score. s Specifically: Alternatively, the anomaly score can be optimized using nearest neighbor features. The optimized anomaly score is as follows: in, For test images, For test images The feature set obtained after feature extraction These are the feature vectors in the feature memory pool M'. , indicating that the feature memory pool M' contains and The nearest feature vector, It is a feature memory pool middle The set of nearest neighbor features.
[0041] The initial abnormal score s The minimum Euclidean distance can initially reflect the degree of difference between the test feature and the normal baseline feature. The larger the minimum Euclidean distance, the more significant the difference between the test feature and the most similar baseline feature in the memory pool, and the higher the probability that the region is an anomalous region. This optimized anomalous score can more accurately characterize the degree of anomalousness of the test feature, effectively reduce the risk of misjudgment caused by comparison of a single feature, and provide a more reliable basis for subsequent accurate classification.
[0042] In S500, anomaly detection thresholds are set. The calculated abnormal scores s and Comparison: If If the feature corresponds to a defective region, then the test image region is determined to be a defective region (since the trained feature memory pool already contains heterogeneous features of defects, no abnormal response will be generated to defective regions during testing); if If the region is determined to be a normal region or a defective region, then an anomaly segmentation map is generated by upsampling and spatial alignment patch-level scores.
[0043] In one embodiment, a system for detecting surface defects and flaws in automotive parts based on feature heterogeneity measurement is also provided, comprising the steps of performing a method for detecting surface defects and flaws in automotive parts based on feature heterogeneity measurement, including: The initial memory pool construction module is used to obtain defect-free normal automotive parts samples and construct the initial feature memory pool; The memory pool update module is used to obtain automotive parts samples containing defects, extract defect sample features through a pre-trained feature extractor, and calculate the heterogeneity measure between the defect sample features and the features in the initial feature memory pool based on two dimensions: linear similarity and nonlinear independence. Based on the heterogeneity measure, the defect sample features are selectively updated to the initial feature memory pool to form an updated feature memory pool. The homogeneous feature self-distillation module is used to perform a homogeneous feature self-distillation process on the updated feature memory pool. It identifies and removes redundant homogeneous features by calculating the heterogeneity between feature pairs, resulting in a simplified feature memory pool. The test feature extraction module is used to acquire surface images of the automotive parts to be inspected and extract their test features using the same feature extractor as in the training phase. The anomaly detection and classification module compares the test features with the baseline features in the simplified feature memory pool, calculates the anomaly score, and classifies the test features according to the preset anomaly score threshold to identify normal areas, flawed areas, and defective areas in the image to be detected.
[0044] Specific limitations regarding the system for detecting surface defects and imperfections in automotive parts based on feature heterogeneity measurement can be found in the limitations of the method for detecting surface defects and imperfections in automotive parts based on feature heterogeneity measurement mentioned above, and will not be repeated here. Each module in the aforementioned system for detecting surface defects and imperfections in automotive parts based on feature heterogeneity measurement can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0045] The above-mentioned method and system for detecting surface defects and flaws in automotive parts based on feature heterogeneity measurement has the following advantages compared to existing technologies: (1) Effectively distinguish between defects and flaws: The heterogeneity measurement feature memory pool update strategy proposed in this invention eliminates homogeneous features, retains heterogeneous features and updates the memory pool by measuring the linear and nonlinear correlation between defect and flaw features (combining cosine similarity and HSIC independence measurement). This solves the problem that existing anomaly detection methods uniformly regard all non-ideal states as anomalies and cannot distinguish between defects and flaws. It meets the actual needs of industrial production where minor defects are acceptable and serious defects must be prohibited. It reduces the workload of re-inspection workers and improves production quality and efficiency. (2) Improve model deployability: By using the homogeneous feature self-distillation strategy, redundant homogeneous features in the feature memory pool are eliminated, significantly reducing the memory usage and inference time of the detection model deployment, greatly improving the application capability of the method in resource-constrained industrial scenarios, and meeting the real-time requirements in actual production. (3) Excellent detection performance: The experimental results of the system show that the proposed FHM-MPD method is significantly better than the existing advanced anomaly detection methods in the defect and anomaly detection dataset of automotive parts and the public dataset MVTec AD, which greatly improves the production quality and efficiency of automotive parts industrial products. (4) Strong applicability: It does not rely on a large number of labeled defect samples. It can achieve efficient detection based on unsupervised or semi-supervised learning mode. It is suitable for defect detection tasks of automotive parts that lack defect samples, and can also adapt to the dynamic environmental changes of automotive manufacturing production lines.
[0046] In one embodiment, a computer device is also provided, including a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of a method for detecting surface defects and flaws of automotive parts based on feature heterogeneity measurement.
[0047] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0048] The foregoing has provided a detailed description of the method and system for detecting surface defects and flaws in automotive parts based on feature heterogeneity measurement, as provided by this invention. Specific examples have been used to illustrate the principles and implementation methods of this invention, and the descriptions of the embodiments above are merely for the purpose of helping to understand the core ideas of this invention. It should be noted that those skilled in the art can make various improvements and modifications to this invention without departing from the principles of this invention, and these improvements and modifications also fall within the protection scope of the claims of this invention.
Claims
1. A method for detecting surface defects and flaws in automotive parts based on feature heterogeneity measurement, characterized in that, Includes the following steps: S100: Obtain defect-free normal automotive parts samples and construct an initial feature memory pool; S200: Obtain samples of automotive parts containing defects, extract features of defective samples through a pre-trained feature extractor, and calculate the heterogeneity measure between the features of defective samples and the features in the initial feature memory pool based on two dimensions: linear similarity and nonlinear independence. Combined with a preset heterogeneity threshold, selectively update the features of defective samples to the initial feature memory pool to form an updated feature memory pool. S300: Perform a homogeneous feature self-distillation process on the updated feature memory pool. By calculating the heterogeneity between feature pairs, redundant homogeneous features are identified and eliminated to obtain a simplified feature memory pool. S400: Acquire surface images of the automotive parts to be inspected, and extract their test features using the same feature extractor as in the training phase; S500: The test features are compared with the baseline features in the simplified feature memory pool to calculate the anomaly score. The test features are then classified and judged according to the preset anomaly score threshold to identify normal areas, flawed areas and defective areas in the image to be detected.
2. The method according to claim 1, characterized in that, S100 includes: S110: Employs a pre-trained neural network model as the basic feature extractor, and defines the neighborhood size as... The feature aggregation function is used to extract local perceptual features from normal automotive parts samples; S120: Collect the features of all normal samples after local perceptual feature aggregation processing, and construct an initial feature memory pool covering multi-level feature information.
3. The method according to claim 2, characterized in that, S110 specifically refers to: At each location in the feature map ( h , w The feature vectors within the aggregated neighborhood are aggregated. Defined as: in, For the size of the neighborhood, and These represent the position indices in the height and width directions of the feature map, respectively. and These represent the height and width coordinates of the pixels in the neighborhood, respectively. Location( h , w Local perceptual features at ) for: in, It is an aggregate function. It is a normal sample x i In the network j Location of layer extraction Features of the location; S120 specifically refers to: in, It is a collection of all defect-free, normal automotive parts samples. j These are indices for different levels of a pre-trained neural network. h , w This iterates through all positions on the feature map. This serves as the initial feature memory pool.
4. The method according to claim 2, characterized in that, S200 includes: S210: Use the same feature extractor as the one used to construct the initial feature memory pool to perform consistent feature extraction on multiple defective samples. The parameter settings of the feature extractor include the neural network model and the neighborhood size. Aggregate functions To obtain the features of each defect sample ; S220: Calculate the characteristics of defective samples With feature memory pool Chinese characteristics cosine similarity s i As a result of linear similarity measurement, specifically: S230: Using stochastic Fourier transform to characterize defective samples and feature memory pool Chinese characteristics The transformation is performed, and the independence between the two is measured using the Hilbert-Schmidt independence criterion. As a measure of nonlinear independence, the specific result is as follows: in This represents the random Fourier transform operation. Represents the Hilbert-Schmidt independence criterion; S240: Calculate Independence Similarity s i The difference between As a measure of heterogeneity, it is specifically: S250: Set heterogeneity threshold τ ,like h > τ Then the features of the defective samples will be... Add to feature memory pool In the process, the updated feature memory pool is obtained. .
5. The method according to claim 4, characterized in that, The S300 includes: For the updated feature memory pool Each pair of features Calculate its heterogeneity measure. h ij The calculation formula is: in, It is a feature and The results of the independence measurement, It is the cosine similarity between the two; Set a threshold for homogeneous features τ' ,like h ij < τ' Then determine the feature and For redundant homogeneous features, and from the feature memory pool By removing one of the features, a simplified feature memory pool containing only non-redundant heterogeneous features is obtained. M' .
6. The method according to claim 5, characterized in that, The S400 uses the same feature extractor as the training phase for the test images. Local perceptual feature extraction is performed to obtain the feature set of the test image. .
7. The method according to claim 6, characterized in that, The calculation of outlier scores in S500 includes: For each feature of the test image Calculate its relationship with the simplified feature memory pool. The minimum Euclidean distance among all features is used, and the maximum distance value among all features is taken as the anomaly score. s Specifically: Alternatively, the anomaly score can be optimized using nearest neighbor features. The optimized anomaly score is as follows: in, For test images, For test images The feature set obtained after feature extraction These are the feature vectors in the feature memory pool M'. , indicating that the feature memory pool M' contains and The nearest feature vector, It is a feature memory pool middle The nearest neighbor feature set.
8. The method according to claim 7, characterized in that, In S500, anomaly detection thresholds are set. The calculated abnormal scores s and Comparison: If If the test image region corresponding to the feature is determined to be a defect region; if If the region is determined to be a normal region or a defective region, then an anomaly segmentation map is generated by upsampling and spatial alignment patch-level scores.
9. A system for detecting surface defects and flaws in automotive parts based on feature heterogeneity measurement, used to perform the steps of the method as described in any one of claims 1 to 8, characterized in that, include: The initial memory pool construction module is used to obtain defect-free normal automotive parts samples and construct the initial feature memory pool; The memory pool update module is used to obtain automotive parts samples containing defects, extract defect sample features through a pre-trained feature extractor, and calculate the heterogeneity measure between the defect sample features and the features in the initial feature memory pool based on two dimensions: linear similarity and nonlinear independence. Based on the heterogeneity measure, the defect sample features are selectively updated to the initial feature memory pool to form an updated feature memory pool. The homogeneous feature self-distillation module is used to perform a homogeneous feature self-distillation process on the updated feature memory pool. It identifies and removes redundant homogeneous features by calculating the heterogeneity between feature pairs, resulting in a simplified feature memory pool. The test feature extraction module is used to acquire surface images of the automotive parts to be inspected and extract their test features using the same feature extractor as in the training phase. The anomaly detection and classification module compares the test features with the baseline features in the simplified feature memory pool, calculates the anomaly score, and classifies the test features according to the preset anomaly score threshold to identify normal areas, flawed areas, and defective areas in the image to be detected.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Ceramic tile flaw detection method and device and electronic equipment
CN114299040A
Unmanned aerial vehicle inspection defect classification method and device based on similarity consistency self-distillation
CN115457006A
