A robust method and system for industrial part surface defect detection

CN121258875BActive Publication Date: 2026-10-09WUHAN INST OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511190403.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-25
Publication Date
2026-10-09
Estimated Expiration
2045-08-25

AI Technical Summary

Technical Problem

然而在实际工业场景中,缺陷样本通常数量稀少、类型多样且分布极不均衡,导致标注成本高昂且难以覆盖所有异常模式,限制了监督学习方法的实际应用效果

Benefits of technology

本发明的方法通过静态引导模块与动态重建模块的双分支协作架构,结合图像分块随机掩蔽与多尺度特征重构机制,有效强化了模型对遮挡条件和复杂环境的适应能力,显著提高了缺陷区域的识别灵敏度与定位准确性,在确保较高检测精度的同时维持了良好的计算效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121258875B_ABST
    Figure CN121258875B_ABST
Patent Text Reader

Abstract

The application relates to an industrial part surface defect detection method and system with robustness, which comprises the following steps: inputting an industrial part image into a parameter-frozen static guide module to extract a multi-scale semantic feature map; performing image blocking and random masking to generate a partial-missing image block sequence, inputting the image block sequence into a dynamic reconstruction module to perform feature extraction and fusion, and obtaining a fusion feature representation; performing multi-scale semantic reconstruction on the feature to generate a reconstruction feature map corresponding to the multi-scale feature map of the static module; and calculating an abnormal score map based on the multi-scale feature map and the reconstruction feature map to identify and locate a defect area. Through the double-branch collaborative architecture of the static guide module and the dynamic reconstruction module, in combination with the image blocking random masking and the multi-scale feature reconstruction mechanism, the adaptability of the model to the masking condition and the complex environment is strengthened, the identification sensitivity and the positioning accuracy of the defect area are improved, the high detection precision is ensured, and good calculation efficiency is maintained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing and artificial intelligence interdisciplinary application technology, and in particular to a robust method and system for detecting surface defects in industrial parts. Background Technology

[0002] Currently, surface defect detection of industrial parts mainly employs supervised learning-based deep learning methods, which heavily rely on a large number of high-quality labeled defect samples for training. However, in real-world industrial scenarios, defect samples are typically scarce, diverse in type, and highly unevenly distributed, leading to high annotation costs and difficulty in covering all anomaly patterns, thus limiting the practical application effectiveness of supervised learning methods. While unsupervised anomaly detection methods that have emerged in recent years reduce reliance on defect samples, they still exhibit insufficient robustness when facing complex conditions in real-world industrial environments, such as domain shifts, scale changes, and positional perturbations. In particular, image reconstruction-based methods, due to their limited receptive field and weak contextual modeling capabilities, often suffer from errors or omissions in anomaly region reconstruction, resulting in high false positive and false negative rates, making it difficult to meet the demands of high-precision industrial inspection.

[0003] Therefore, there is an urgent need to provide a technical solution to address the above problems. Summary of the Invention

[0004] To address the aforementioned technical problems, this invention provides a robust method and system for detecting surface defects in industrial parts.

[0005] Firstly, the present invention provides a robust method for detecting surface defects in industrial parts, the technical solution of which is as follows: The system acquires input images of industrial parts and inputs these images into a statically guided module with frozen parameters to extract multi-scale semantic feature maps. The input image is segmented and randomly occluded to generate a sequence of image blocks with missing information. The image block sequence is then input into the dynamic reconstruction module for feature extraction and fusion to obtain the fused image feature representation. Multi-scale semantic reconstruction is performed on the image feature representation to generate a multi-scale reconstructed feature map corresponding to the multi-scale semantic feature map output by the static guidance module; Based on multi-scale semantic feature maps and multi-scale reconstructed feature maps, multi-scale anomaly scoring maps are calculated, and defective regions in the input image are identified and located according to the multi-scale anomaly scoring maps.

[0006] The beneficial effects of the robust surface defect detection method for industrial parts of the present invention are as follows: The method of this invention, through a dual-branch collaborative architecture of a static guidance module and a dynamic reconstruction module, combined with image block random masking and multi-scale feature reconstruction mechanism, effectively enhances the model's adaptability to occlusion conditions and complex environments, significantly improves the identification sensitivity and localization accuracy of defect areas, and maintains good computational efficiency while ensuring high detection accuracy.

[0007] Based on the above scheme, the robust industrial part surface defect detection method of the present invention can be further improved as follows.

[0008] In one alternative approach, the step of extracting multi-scale semantic feature maps includes: Multi-scale semantic feature maps are obtained by extracting features from input images using a hierarchical encoder pre-trained on a large image dataset. The pre-trained hierarchical encoder is configured to abstract layer by layer, outputting at least three sets of feature maps with different spatial resolutions and semantic depths. The feature maps retain low-level detail information and high-level semantic information respectively from shallow to deep layers.

[0009] Among the above-mentioned alternative approaches, by employing a hierarchical encoder pre-trained on a large dataset as a static guiding module, it is possible to stably and efficiently extract multi-scale feature maps containing everything from low-level details to high-level semantics. These feature maps provide rich and reliable supervision signals for subsequent dynamic reconstruction, significantly enhancing the model's ability to perceive different granular features on the surface of industrial parts, and laying a solid foundation for high-precision defect detection.

[0010] In one optional approach, the input image is segmented and randomly occluded to generate a sequence of image patches with partially missing information. This sequence is then input into a dynamic reconstruction module for feature extraction and fusion to obtain the fused image feature representation. The steps include: The input image is divided into multiple fixed-size image sub-blocks to obtain an initial image block sequence; With a preset occlusion ratio, some image sub-blocks in the initial image block sequence are randomly selected for occlusion, forming an image block sequence with partially missing information; For unoccluded image sub-blocks in a sequence of image blocks with missing information, the corresponding feature vectors are extracted using a dynamic reconstruction module. For occluded image sub-blocks, randomly initialized feature vectors are generated. All the processed feature vectors are concatenated according to their corresponding image sub-block spatial position order to generate the fused image feature representation.

[0011] In the above-mentioned alternative methods, by dividing the image into blocks and randomly occluding some regions, input samples with partially missing information are constructed. This forces the dynamic reconstruction module to learn and utilize the contextual relationships between image blocks to predict the occluded regions, effectively enhancing the model's ability to understand and reason about incomplete information. This improves the robustness and accuracy of detection in real industrial scenarios where information is missing due to occlusion or noise.

[0012] In an alternative approach, a step of training the dynamic reconstruction module is also included, the training step comprising: The dynamic reconstruction module is trained using only normal samples, with the training objective being to minimize the difference between its output multi-scale reconstruction feature map and the multi-scale semantic feature map extracted by the static guidance module. The training objective is achieved through a loss function, which is the sum of the average anomaly scores of all pixels on the anomaly scoring map at each scale. The training adopts a phased learning rate decay strategy and combines weight decay and warm-up mechanisms to optimize the dynamic reconstruction module.

[0013] In the above-mentioned optional methods, by specifying that only normal samples are used to train the dynamic reconstruction module and minimizing the multi-scale reconstruction error, it is ensured that the model can focus on learning the feature distribution of normal samples. Combined with optimization strategies such as phased learning rate decay, the stability and convergence efficiency of the training process are effectively improved, enabling the model to produce significant reconstruction errors when facing unknown defects, thereby achieving efficient and reliable unsupervised anomaly detection.

[0014] In one alternative approach, the step of performing multi-scale semantic reconstruction on the image feature representation to generate a multi-scale reconstructed feature map corresponding to the multi-scale semantic feature map output by the static guidance module includes: The image feature representation is input into the semantic-aware feature enhancement module to perform multi-scale context modeling and spatial axis dependency modeling, and the enhanced feature representation is output. The enhanced feature representation is input into the pyramid feature mapping module for upsampling and feature mapping, generating a multi-scale reconstructed feature map that is aligned with the static guidance module in terms of resolution and number of channels.

[0015] In the above-mentioned optional approach, by introducing the collaboration of the semantic awareness feature enhancement module and the pyramid feature mapping module, the features are first contextualized and spatially structured at multiple scales, and then upsampled and mapped to accurately align them with the static guiding features. This significantly improves the dynamic reconstruction module's ability to understand complex semantics and the accuracy of feature representation, thereby enhancing the model's sensitivity to defects at different scales and its localization accuracy.

[0016] In one alternative approach, the steps of inputting the image feature representation into a semantically aware feature enhancement module, performing multi-scale context modeling and spatial axis dependency modeling, and outputting the enhanced feature representation include: Local detail modeling is performed on the image feature representation to obtain initial detail features; Multiple convolutional operations with different receptive fields are used in parallel to extract multi-scale contextual features; The initial detailed features are fused with multi-scale contextual features to generate a fused feature map; Global feature compression is performed on the image feature representation, and axial strip convolution is applied to establish spatial axial dependencies and generate spatial weighting coefficients; The fused feature map is weighted using spatial weighting coefficients to output an enhanced feature representation.

[0017] Among the above optional methods, the operation process of the semantic awareness feature enhancement module is defined in detail. It captures multi-scale context through parallel multi-receptive field convolution and establishes spatial dependency relationship to generate attention weights by combining axial convolution. Finally, the features are weighted and fused. This mechanism significantly enhances the model's ability to perceive local details and global structure of the image, effectively improves the quality of feature representation and the detection rate of minor anomalies and structural defects.

[0018] In one alternative approach, the step of inputting the enhanced feature representation into the pyramid feature mapping module for upsampling and feature mapping to generate a multi-scale reconstructed feature map aligned with the static guidance module in terms of resolution and number of channels includes: The enhanced feature representation is input as a high semantic feature map into the pyramid feature mapping module, and the high semantic feature map is upsampled step by step to obtain feature maps of different scales; The feature maps after each upsampling stage are sequentially subjected to channel mapping convolution, normalization, and smoothing convolution operations to generate the final multi-scale reconstructed feature map aligned with the features of the static guidance module.

[0019] In the above-mentioned optional methods, through the pyramid feature mapping module's step-by-step upsampling and a series of convolution and normalization operations, high semantic and low-resolution features are gradually restored and mapped to a multi-scale space that matches the static guiding features. This process effectively bridges the semantic and scale gap between the two modules, ensures the effectiveness of knowledge transfer, improves the spatial consistency and accuracy of reconstructed features, and provides a reliable guarantee for subsequent accurate calculation of anomaly scores.

[0020] In one alternative approach, the step of calculating a multi-scale anomaly scoring map based on multi-scale semantic feature maps and multi-scale reconstructed feature maps includes: For each scale of semantic feature map and reconstructed feature map, calculate the cosine similarity between their feature vectors at the corresponding spatial locations; Subtracting the cosine similarity value from 1 gives the anomaly score for that spatial location at the current scale. Anomaly scores at all scales and in all spatial locations are aggregated to form a multi-scale anomaly score map.

[0021] Among the above-mentioned optional methods, cosine similarity is used as a metric to calculate feature differences at each position and generate anomaly scores. The larger the value, the greater the reconstruction error and the higher the probability of anomalies. This method can keenly capture subtle deviations in the feature space and is particularly effective for texture anomalies, structural defects, etc., thereby achieving pixel-level accurate anomaly perception and generating more reliable anomaly score maps with less noise for subsequent localization.

[0022] In one alternative approach, the step of identifying and locating defect regions in the input image based on a multi-scale anomaly scoring map includes: The multi-scale anomaly scoring maps are fused and post-processed to generate the final defect location heatmap. Threshold processing is applied to the defect location heatmap to identify areas with abnormal scores higher than a preset threshold as defect areas and output the corresponding location information.

[0023] In the above-mentioned optional methods, by fusing and post-processing the multi-scale anomaly scoring maps to generate a heat map, and applying threshold segmentation to finally determine the defect area, this process can integrate anomaly information at various scales, suppress false alarms, highlight the real defect signals, and finally output clear and accurate defect location results, which greatly improves the practicality and reliability of the output results of the entire detection system and makes it easy to integrate into automated quality inspection lines.

[0024] Secondly, the present invention provides a robust industrial parts surface defect detection system, the technical solution of which is as follows: The robust industrial part surface defect detection system includes: a static guidance unit, a dynamic reconstruction unit, and a defect analysis unit; The static guidance unit is used to: acquire an input image of an industrial part, and extract features from the input image using a hierarchical encoder pre-trained on a large image dataset with frozen parameters to obtain a multi-scale semantic feature map, wherein the pre-trained hierarchical encoder is configured to abstract layer by layer and output at least three sets of feature maps with different spatial resolutions and semantic depths. The dynamic reconstruction unit is used to: divide the input image into multiple fixed-size image sub-blocks to obtain an initial image block sequence; randomly select some image sub-blocks in the initial image block sequence to occlude them according to a preset occlusion ratio, forming an image block sequence with partially missing information; extract the corresponding feature vectors of the uncrowded image sub-blocks in the partially missing information image block sequence, and generate randomly initialized feature vectors for the occluded image sub-blocks; concatenate all the processed feature vectors according to their corresponding spatial position order of the image sub-blocks to generate a fused image feature representation; and input the image feature representation into the semantic awareness feature enhancement module for multi-scale contextualization. Modeling and spatial axis dependency relationship modeling are used to output enhanced feature representations. The enhanced feature representations are then input into the pyramid feature mapping module for upsampling and feature mapping to generate multi-scale reconstructed feature maps that are aligned with the static guidance module in terms of resolution and number of channels. The dynamic reconstruction module is trained using only normal samples. Its training objective is to minimize the difference between the multi-scale reconstructed feature maps and the multi-scale semantic feature maps extracted by the static guidance module. The training objective is achieved through a loss function, which is the sum of the average values ​​of the anomaly scores of all pixels on each scale anomaly scoring map. The training process adopts a phased learning rate decay strategy combined with weight decay and a warm-up mechanism. The defect analysis unit is used to: calculate the cosine similarity between the feature vectors at the corresponding spatial locations for each scale's semantic feature map and reconstructed feature map; subtract the cosine similarity from 1 as the anomaly score for that spatial location at the current scale; summarize the anomaly scores at all scales and all spatial locations to form a multi-scale anomaly score map; fuse and post-process the multi-scale anomaly score map to generate the final defect location heatmap; apply threshold processing to the defect location heatmap, determine areas with anomaly scores higher than a preset threshold as defect areas, and output the corresponding location information.

[0025] The beneficial effects of the robust industrial part surface defect detection system of the present invention are as follows: The system of this invention, through a dual-branch collaborative architecture of a static guidance module and a dynamic reconstruction module, combined with image block random masking and multi-scale feature reconstruction mechanism, effectively enhances the model's adaptability to occlusion conditions and complex environments, significantly improves the identification sensitivity and localization accuracy of defect areas, and maintains good computational efficiency while ensuring high detection accuracy.

[0026] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description

[0027] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings: Figure 1 This is a schematic flowchart of a robust method for detecting surface defects in industrial parts according to the present invention. Figure 2 This is a schematic diagram of the dynamic reconstruction module and its multi-scale semantic reconstruction framework in this embodiment; Figure 3 This is a schematic diagram illustrating the principle of the abnormal score map generation and calculation method in this embodiment; Figure 4 This is a diagram showing the anomaly detection results of this invention on the MVTec dataset (and its perturbation categories); Figure 5 This is a diagram showing the anomaly detection results of this invention on the MPDD dataset; Figure 6 This is a diagram showing the anomaly detection results of this invention on the AeBAD-S dataset; Figure 7 This is a schematic diagram of the structure of a robust industrial part surface defect detection system according to the present invention. Detailed Implementation

[0028] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be limited to the embodiments set forth herein.

[0029] Figure 1 This diagram illustrates a flow chart of an embodiment of a robust method for detecting surface defects in industrial parts provided by the present invention, which is executed by xx. Figure 1 As shown, it includes the following steps: S1. Obtain the input image of the industrial part and input the input image into the static guidance module with frozen parameters to extract multi-scale semantic feature maps. In S1: 1) The static guidance module is a network module whose parameters are fixed and does not participate in the model training process. Its role is to provide stable and high-quality feature references throughout the process.

[0030] 2) Multi-scale semantic feature maps refer to a set of feature maps output by different network layers with different spatial sizes and semantic abstraction levels. Shallow feature maps contain more details and texture information, while deep feature maps contain more semantic and global information.

[0031] Specifically, the acquired images of industrial parts are input into this static guidance module. This module typically consists of a deep convolutional neural network (such as WideResNet50) pre-trained on a large, publicly available image dataset (such as ImageNet). During forward propagation, the network extracts multiple sets of feature maps from its different intermediate layers. These feature maps form the benchmark for comparison and computation in subsequent steps.

[0032] S2. The input image is segmented and randomly occluded to generate a sequence of image patches with missing information. This sequence is then input into the dynamic reconstruction module for feature extraction and fusion to obtain the fused image feature representation. In S2: 1) Blocking refers to dividing a complete input image into multiple fixed-size, non-overlapping square image blocks. Its purpose is to convert the image into a series of serialization units that can be processed by structures such as Transformer.

[0033] 2) Random occlusion refers to randomly selecting a portion of image blocks according to a pre-set ratio and setting their pixel values ​​to zero or replacing them with a specific mask to simulate the situation of missing information, thereby forcing the model to learn context-based reasoning ability.

[0034] 3) The dynamic reconstruction module is a network that needs to be trained. Its core task is to use information from the unoccluded area to predict the feature representation that the occluded area should have.

[0035] Specifically, the input image is first cropped or scaled to a uniform size, and then its grid is divided into multiple small image patches. Subsequently, a certain percentage (e.g., 40%) of these patches are randomly selected for occlusion. For unoccluded patches, a feature extractor (e.g., a pre-trained Vision Transformer) in the dynamic reconstruction module is used to obtain the feature vector for each patch; for occluded patches, their corresponding feature vectors are initialized with random values. Finally, the feature vectors of all image patches are reassembled according to their spatial order in the original image, forming a fused feature representation that characterizes the entire image while also including some missing information.

[0036] S3. Perform multi-scale semantic reconstruction on the image feature representation to generate a multi-scale reconstructed feature map corresponding to the multi-scale semantic feature map output by the static guidance module. In S3: 1) Multi-scale semantic reconstruction refers to using the neural network inside the dynamic reconstruction module to process the fused feature representation obtained in S2, and gradually recover and output its complete feature expression at multiple scales.

[0037] 2) Multi-scale reconstructed feature maps refer to the multi-scale semantic features output by the static guidance module in S1 at multiple scales. Figure 1 A corresponding feature map generated by the dynamic reconstruction module, the goal of which is to reconstruct the features of normal samples as accurately as possible.

[0038] 3) The semantic awareness feature enhancement module is a sub-component in the dynamic reconstruction network. It captures contextual information of different ranges by using multiple convolutional kernels of different sizes in parallel and models dependencies in spatial directions to enhance the robustness and expressiveness of features.

[0039] 4) The pyramid feature mapping module is another sub-component in the dynamic reconstruction network. It is responsible for upsampling and transforming the enhanced features to align them with the multi-scale feature maps provided by the static guidance module in terms of resolution and number of channels, so as to enable accurate difference comparisons in the future.

[0040] Specifically, the fused image feature representation is input into the core network of the dynamic reconstruction module. This network first enhances the expressive power of the features and their robustness to scale and location changes through a semantically aware feature enhancement module. Then, the enhanced features are fed into a pyramid feature mapping module, which progressively upsamples and maps the feature maps to different scales through a feature pyramid structure, ultimately generating a set of reconstructed feature maps that correspond one-to-one with the multi-scale semantic feature maps output by the static guidance module in terms of resolution and number of channels.

[0041] S4. Based on the multi-scale semantic feature map and the multi-scale reconstructed feature map, calculate the multi-scale anomaly scoring map, and identify and locate the defect region in the input image according to the multi-scale anomaly scoring map. In S4: 1) A multi-scale anomaly rating map is a two-dimensional map calculated at multiple scales, with a value for each spatial location. The magnitude of the value reflects the probability that the location is an anomaly, and the larger the value, the higher the probability of an anomaly.

[0042] 2) Identification and localization refers to first determining whether there are defects in the entire image (image-level classification), and then accurately pointing out which pixel areas of the image the defects exist in (pixel-level segmentation).

[0043] Specifically, for each pair of feature maps corresponding to different scales, the cosine similarity between the two feature vectors is calculated at each identical spatial coordinate location on the feature maps. Subtracting this similarity value from 1 yields the preliminary anomaly score for that location at that scale. The anomaly score maps calculated at all scales are then fused (e.g., by upsampling to the original image size and averaging the results) to generate a comprehensive anomaly heatmap. Finally, a threshold is set on this heatmap; regions with scores exceeding this threshold are identified as defective regions, and their bounding boxes or pixel-level masks are output, thus completing the identification and precise localization of defects.

[0044] The technical solution of this embodiment, through a dual-branch collaborative architecture of a static guidance module and a dynamic reconstruction module, combined with image block random masking and multi-scale feature reconstruction mechanism, effectively enhances the model's adaptability to occlusion conditions and complex environments, significantly improves the identification sensitivity and localization accuracy of defect areas, and maintains good computational efficiency while ensuring high detection accuracy.

[0045] In one alternative approach, the step of extracting multi-scale semantic feature maps includes: Multi-scale semantic feature maps are obtained by extracting features from input images using a hierarchical encoder pre-trained on a large image dataset. The pre-trained hierarchical encoder is configured to abstract layer by layer, outputting at least three sets of feature maps with different spatial resolutions and semantic depths. The feature maps retain low-level detail information and high-level semantic information respectively from shallow to deep layers.

[0046] In this embodiment, the input image (its size is...) The input image (representing height, width, and number of channels, respectively) is first fed into the static guidance module for feature extraction. The static guidance module performs forward propagation computation on the input image using a hierarchical encoder structure WideResNet50 pre-trained on the large image dataset ImageNet, thereby completing feature extraction.

[0047] The three sets of feature maps output by the encoder are denoted as follows: These correspond to the multi-scale semantic representations of the network from shallow to deep layers, and together constitute the multi-scale semantic feature map. Among them, the shallow feature map... The spatial resolution is With 256 channels, it primarily preserves low-level details and texture information of the input image; the mid-level feature map... The spatial resolution is The number of channels is 512; deep feature map The spatial resolution is With 1024 channels, it contains higher-level semantic information. The multi-scale feature map not only fully preserves the low-level details and high-level semantics of the image, but also effectively enhances the model's ability to perceive complex structures and local changes.

[0048] These features can be used to supervise the training process of the dynamic reconstruction module, specifically to guide the dynamic reconstruction module to complete the mask-based feature recovery task. By randomly occluding parts of the input image and requiring the dynamic reconstruction module to reconstruct the corresponding static guidance module features based only on the visible regions, the model is forced to learn the structural dependencies and contextual relationships between different regions within the image.

[0049] In one optional approach, the input image is segmented and randomly occluded to generate a sequence of image patches with partially missing information. This sequence is then input into a dynamic reconstruction module for feature extraction and fusion to obtain the fused image feature representation. The steps include: The input image is divided into multiple fixed-size image sub-blocks to obtain an initial image block sequence; With a preset occlusion ratio, some image sub-blocks in the initial image block sequence are randomly selected for occlusion, forming an image block sequence with partially missing information; For unoccluded image sub-blocks in a sequence of image blocks with missing information, the corresponding feature vectors are extracted using a dynamic reconstruction module. For occluded image sub-blocks, randomly initialized feature vectors are generated. All the processed feature vectors are concatenated according to their corresponding image sub-block spatial position order to generate the fused image feature representation.

[0050] In an alternative approach, a step of training the dynamic reconstruction module is also included, the training step comprising: The dynamic reconstruction module is trained using only normal samples, with the training objective being to minimize the difference between its output multi-scale reconstruction feature map and the multi-scale semantic feature map extracted by the static guidance module. The training objective is achieved through a loss function, which is the sum of the average anomaly scores of all pixels on the anomaly scoring map at each scale. The training adopts a phased learning rate decay strategy and combines weight decay and warm-up mechanisms to optimize the dynamic reconstruction module.

[0051] It should be noted that the training of this method is based on unsupervised learning, that is, only using defect-free normal samples. During the training process, the dynamic reconstruction module only learns and models the feature structure of normal samples (defect-free samples), and gradually captures their potential distribution patterns and structural consistency by continuously learning and reconstructing the features generated by the static module.

[0052] In this embodiment, the input image is first adjusted to a size of 256×256 pixels and then cropped from the center to obtain an image with a size of 224×224 pixels; The cropped image is divided into 16×16 pixel sub-blocks, resulting in a total of 14×14=196 sub-blocks, forming the initial image block sequence; With a preset occlusion ratio (e.g., 40%), some image sub-blocks in the initial image block sequence are randomly selected for occlusion processing to form an image block sequence with partially missing information; For unoccluded image sub-blocks in a sequence of image blocks with missing information, the corresponding feature vectors are extracted using the pre-trained ViT-B (Vision Transformer Base), with a feature dimension of 768. For the occluded image sub-blocks, generate randomly initialized feature vectors with a feature dimension of 768 to avoid information leakage. All feature vectors obtained from the above processing are concatenated according to the spatial position of their corresponding image sub-blocks in the original image to generate a fused image feature representation F with a dimension of 14×14×768.

[0053] For the training of the dynamic reconstruction module, only normal samples are used to train the dynamic reconstruction module. The training objective is to minimize the difference between its output multi-scale reconstruction feature map and the multi-scale semantic feature map extracted by the static guidance module. The training objective is achieved through a loss function, which is the sum of the average values ​​of all pixel anomaly scores on the anomaly score map at each scale. Specifically, for the feature map of the i-th layer, the loss function of that layer is defined. For the corresponding anomaly diagram The average value of all pixels, i.e.: = ; in, and Let represent the height and width of the feature map at layer i, respectively, and ∑ denote the summation operation. For spatial location Abnormal ratings at the location.

[0054] The final overall loss function The summation of losses at each scale is used to guide the dynamic reconstruction module in reconstructing normal features in a multi-level semantic space. The specific calculation formula is as follows: ; This loss design can simultaneously take into account the reconstruction errors of local details and global semantics, effectively improving the model's ability to perceive anomalies at different scales.

[0055] The AdamW optimizer was used during training, with the momentum parameter set to [value missing]. , A phased learning rate decay strategy is adopted, specifically: in the first 50 epochs, the learning rate is gradually increased to 0.001 through warm-up, and then in the next 600 epochs, the learning rate is gradually reduced by combining weight decay (0.05) and scheduling mechanism to promote convergence and improve generalization performance; the total number of training rounds is 650, and the batch size is 12.

[0056] In one alternative approach, the step of performing multi-scale semantic reconstruction on the image feature representation to generate a multi-scale reconstructed feature map corresponding to the multi-scale semantic feature map output by the static guidance module includes: The image feature representation is input into the semantic-aware feature enhancement module to perform multi-scale context modeling and spatial axis dependency modeling, and the enhanced feature representation is output. The enhanced feature representation is input into the pyramid feature mapping module for upsampling and feature mapping, generating a multi-scale reconstructed feature map that is aligned with the static guidance module in terms of resolution and number of channels.

[0057] In one alternative approach, the steps of inputting the image feature representation into a semantically aware feature enhancement module, performing multi-scale context modeling and spatial axis dependency modeling, and outputting the enhanced feature representation include: Local detail modeling is performed on the image feature representation to obtain initial detail features; Multiple convolutional operations with different receptive fields are used in parallel to extract multi-scale contextual features; The initial detailed features are fused with multi-scale contextual features to generate a fused feature map; Global feature compression is performed on the image feature representation, and axial strip convolution is applied to establish spatial axial dependencies and generate spatial weighting coefficients; The fused feature map is weighted using spatial weighting coefficients to output an enhanced feature representation.

[0058] In one alternative approach, the step of inputting the enhanced feature representation into the pyramid feature mapping module for upsampling and feature mapping to generate a multi-scale reconstructed feature map aligned with the static guidance module in terms of resolution and number of channels includes: The enhanced feature representation is input as a high semantic feature map into the pyramid feature mapping module, and the high semantic feature map is upsampled step by step to obtain feature maps of different scales; The feature maps after each upsampling stage are sequentially subjected to channel mapping convolution, normalization, and smoothing convolution operations to generate the final multi-scale reconstructed feature map aligned with the features of the static guidance module.

[0059] It should be noted that, to address the diversity of samples in size and location, as well as the perceptual shift and reconstruction difficulties caused by background interference and illumination changes, this invention introduces a semantic perceptual feature enhancement module to improve the robustness of feature extraction in complex environments. This module effectively alleviates the perceptual obstacles caused by domain shift. Subsequently, through a simple feature pyramid mapping structure, its output features are aligned spatially and semantically with the multi-scale features in the static guidance path.

[0060] The semantic-aware feature enhancement module employs a multi-receptive-field grouped convolutional structure to process image features at different scales in parallel, achieving dense and hierarchical feature extraction and enhancing the model's ability to perceive multi-scale semantics and complex spatial structures. Simultaneously, two sequentially arranged single-axis perceptual convolutional kernels are introduced to model axial semantic dependencies along the vertical and horizontal directions, respectively, strengthening the structural focus on the central region and its context, and effectively improving foreground sensitivity during feature reconstruction.

[0061] Figure 2 This is a schematic diagram of the dynamic reconstruction module and its multi-scale semantic reconstruction framework. As shown in the figure, this module fully demonstrates the processing flow from the input image to the generation of multi-scale reconstructed feature maps. Its workflow mainly includes the following steps: The input image is first segmented and randomly occluded to generate a sequence of image patches with partially missing information. Then, feature vectors are extracted from the unoccluded image patches, and random initialization vectors are generated for the occluded image patches. All feature vectors are then concatenated according to their spatial positions to form a fused image feature representation. This feature representation is then input to the semantic-aware feature enhancement module to model multi-scale context and spatial axis dependencies, and outputs the enhanced feature representation. Finally, the enhanced features are upsampled and mapped by the pyramid feature mapping module to generate a multi-scale reconstructed feature map that is aligned with the static guidance module in terms of resolution and number of channels.

[0062] In this embodiment, the image feature representation F (with dimensions of 14×14×768) is input into the semantic awareness feature enhancement module to perform multi-scale context modeling and spatial axis dependency modeling, and outputs the enhanced feature representation F. a .

[0063] Specifically, the steps of inputting the image feature representation into the semantic-aware feature enhancement module, performing multi-scale context modeling and spatial axis dependency modeling, and outputting the enhanced feature representation include: performing local detail modeling on the image feature representation F, and obtaining initial detail features through a 3×3 depthwise separable convolution operation. ,Right now: = ; Here, DWConv represents depthwise separable convolution operation.

[0064] Multiple convolutional operations with different receptive fields are used in parallel to extract multi-scale contextual features, using a set of convolutional kernels with a size of [missing value]. (in The depthwise separable convolutional units (i=1,2,3,4) are respectively used for... Processing is performed to obtain multi-scale features. ,Right now: = ; Initial detail features Multi-scale contextual features (i from 1 to 4) are fused, and a 1×1 convolutional layer is used to integrate the channel dimensions to generate a fused feature map. ,Right now: ⊕ ; Where Conv represents the standard convolution operation, ⊕ represents element-wise addition, and ∑ represents the summation operation; Global feature compression is performed on the image feature representation F, i.e., a global average pooling operation is applied to it. The mapping is performed through a 1×1 convolutional layer, followed by two orthogonal stripe-shaped depthwise convolution operations (with kernel sizes of k4×1 and 1×k4, respectively) to establish spatial axial dependencies and generate features. The entire process can be represented as follows: ; use Spatial weighting coefficients (attention factors) are generated through a 1×1 convolutional layer and a sigmoid activation function, and then applied to the fused feature map. Perform weighted processing, and finally combine with Residual connection, outputting the enhanced feature representation F a ,Right now: ; in, Represents convolution. This represents a depthwise separable convolution. This indicates the average pooling operation. and These represent strip-shaped depthwise convolutions in two orthogonal directions. It is used to ensure that the value of attention weight is within a certain range. Functions between This indicates element-wise multiplication.

[0065] It should be noted that, to achieve effective knowledge transfer between the static guidance module and the dynamic reconstruction module, a pyramid feature mapping module was designed to bridge the differences between the two in semantic representation and scale space. This module is essentially a simplified top-down mapping structure. By progressively upsampling, convolutional mapping, and standard normalization of the single-scale, high-semantic feature map output by the dynamic reconstruction module, it transforms it into a multi-scale feature map that maintains the same resolution and channel structure as the static guidance module.

[0066] In this embodiment, the enhanced feature representation is... The input is fed into the pyramid feature mapping module for upsampling and feature mapping, generating a multi-scale reconstructed feature map aligned with the static guidance module in terms of resolution and number of channels, including: Enhanced feature representation As a high semantic feature map (denoted as Input is sent to the pyramid feature mapping module; right The first-stage 2×2 transposed convolution upsampling is performed, followed by Gelu activation and layer normalization (LN) to obtain the feature map. ,Right now: ; right A second-stage 2×2 transposed convolution upsampling is performed, followed by Gelu activation and layer normalization to obtain the feature map. ,Right now: ; The feature maps obtained from each level of upsampling (including) , and The process (often referred to as "the module") proceeds as follows: First, a 1×1 convolutional layer is used for channel mapping, followed by layer normalization (LN). Then, a 3×3 convolutional layer is used to enhance the local receptive field. Finally, layer normalization is performed again to generate a multi-scale reconstructed feature map that is aligned with the static guidance module features in terms of resolution and number of channels. This process is uniformly represented as: ; Where Conv represents the convolution operation; LN represents the LayerNorm normalization operation; Gelu represents the activation function based on the Gaussian error linear unit; and Deconv represents the transposed convolution (deconvolution) operation.

[0067] In one alternative approach, the step of calculating a multi-scale anomaly scoring map based on multi-scale semantic feature maps and multi-scale reconstructed feature maps includes: For each scale of semantic feature map and reconstructed feature map, calculate the cosine similarity between their feature vectors at the corresponding spatial locations; Subtracting the cosine similarity value from 1 gives the anomaly score for that spatial location at the current scale. Anomaly scores at all scales and in all spatial locations are aggregated to form a multi-scale anomaly score map.

[0068] The steps for identifying and locating defect regions in an input image based on a multi-scale anomaly scoring map include: In one alternative approach, the multi-scale anomaly scoring maps are fused and post-processed to generate the final defect location heatmap. Threshold processing is applied to the defect location heatmap to identify areas with abnormal scores higher than a preset threshold as defect areas and output the corresponding location information.

[0069] In this embodiment, for the semantic feature map of the i-th layer With reconstructed feature map At each spatial location (x, y) on the feature map, calculate the cosine similarity between the corresponding feature vectors; Subtracting the cosine similarity value from 1 gives the anomaly score for the spatial location (x,y) at the current i-th scale. The anomaly scores at all scales (i=1,2,3) and all spatial locations are aggregated to form a multi-scale anomaly score map. Among them, anomaly scoring The computation process can be formally represented as follows: ; Where (x,y) represents the spatial location on the feature map; and It is a length of is a one-dimensional eigenvector; T represents the transpose operation; · represents the vector dot product; The L2 norm of a vector is used to represent the Euclidean norm. yes The larger the value of the vector, the more significant the difference between the location and the characteristics of the static boot module, and the higher the possibility of potential anomalies.

[0070] Figure 3 This is a schematic diagram illustrating the principle of defect map (i.e., anomaly scoring map) generation and calculation in this embodiment. It intuitively explains how to utilize the multi-scale semantic feature map extracted by the static guidance module. Multi-scale reconstruction feature maps output by the dynamic reconstruction module This is used to calculate the final anomaly scoring map for defect localization. As shown in the figure, for each scale i, at each spatial location (x, y) of the feature map, the teacher network feature vector is calculated. Reconstructing feature vectors with student networks and The cosine similarity between the two points. Subtracting this cosine similarity value from 1 gives the anomaly score for that location. The higher the value, the greater the likelihood of an anomaly at that location. Finally, by aggregating anomaly scores across all scales and spatial locations, a multi-scale anomaly scoring map is generated, providing a direct basis for subsequent defect identification and localization.

[0071] To identify and locate defective regions in the input image, anomaly score maps at multiple scales are upsampled to the original image size and then fused into a comprehensive heatmap through aggregation operations (such as taking the maximum or average value pixel by pixel).

[0072] Threshold processing is applied to the defect location heatmap to identify areas with abnormal scores higher than a preset threshold as defect areas and output the corresponding location information (such as defect bounding boxes or pixel-level masks).

[0073] This process can simultaneously achieve image-level anomaly recognition and pixel-level precise positioning, effectively supporting the fault identification and positioning needs in industrial quality inspection.

[0074] To verify the effectiveness and robustness of the method proposed in this invention, this embodiment was tested on several authoritative industrial anomaly detection datasets and compared with current mainstream methods. The test results are as follows: Figure 4-6 As shown.

[0075] Figure 4 This paper demonstrates the performance of the proposed method on the MVTecAD dataset and its perturbation version. To simulate complex disturbances in real industrial environments, four common perturbations—brightness variation, contrast variation, defocus blur, and Gaussian noise—were introduced into the test set. Experimental results show that the proposed method maintains a leading AUROC score under all perturbation types, significantly outperforming existing mainstream methods. This fully demonstrates the strong robustness of the proposed method to common image perturbations, enabling it to stably and accurately detect anomalies in complex imaging environments.

[0076] Figure 5 The results of the proposed method on the MPDD dataset are presented. This dataset contains various small, irregularly distributed defects, and the similarity between normal and abnormal samples is high, posing a significant challenge to the model's feature extraction and detail resolution capabilities. As shown in the figure, the proposed method achieves optimal detection accuracy on multiple subclasses of this dataset, indicating that it can effectively perceive small abnormal features and overcome background interference, making it suitable for high-precision industrial inspection scenarios.

[0077] Figure 6 The performance of this invention on the AeBAD-S dataset is demonstrated. This dataset is characterized by significant domain biases (such as large differences in background, lighting, and viewpoint). Experimental results show that the method of this invention can effectively overcome inter-domain differences, exhibiting accurate anomaly detection capabilities and stable detection performance in different domains. Its excellent cross-domain generalization ability is verified, solving a key challenge faced by unsupervised anomaly detection in practical deployment.

[0078] In summary, a series of experiments have demonstrated that this invention not only performs well in standard scenarios, but also exhibits excellent robustness and generalization ability under complex challenges such as disturbances, micro-defects, and domain shifts, fully meeting the actual needs of high-precision industrial defect detection.

[0079] Figure 7 A schematic diagram of an embodiment of a robust industrial part surface defect detection system 200 provided by the present invention is shown. Figure 7 As shown, the system 200 includes: a static guidance unit 210, a dynamic reconstruction unit 220, and a defect analysis unit 230; The static guidance unit 210 is used to: acquire an input image of an industrial part, and extract features from the input image using a hierarchical encoder pre-trained on a large image dataset with frozen parameters to obtain a multi-scale semantic feature map, wherein the pre-trained hierarchical encoder is configured to abstract layer by layer and output at least three sets of feature maps with different spatial resolutions and semantic depths. The dynamic reconstruction unit 220 is used to: divide the input image into multiple fixed-size image sub-blocks to obtain an initial image block sequence; randomly select some image sub-blocks in the initial image block sequence to occlude them according to a preset occlusion ratio, forming an image block sequence with partially missing information; extract the corresponding feature vectors of the unoccluded image sub-blocks in the partially missing information image block sequence, and generate randomly initialized feature vectors for the occluded image sub-blocks; concatenate all the processed feature vectors according to their corresponding spatial position order of the image sub-blocks to generate a fused image feature representation; and input the image feature representation to the semantic perception feature enhancement module for multi-scale processing. The following modeling and spatial axis dependency modeling are used to output the enhanced feature representation; the enhanced feature representation is input into the pyramid feature mapping module for upsampling and feature mapping to generate a multi-scale reconstructed feature map aligned with the static guidance module in terms of resolution and number of channels; the dynamic reconstruction module is trained using only normal samples, and its training objective is to minimize the difference between the multi-scale reconstructed feature map and the multi-scale semantic feature map extracted by the static guidance module. The training objective is achieved through a loss function, which is the sum of the average values ​​of the anomaly scores of all pixels on the anomaly scoring map at each scale. The training process adopts a phased learning rate decay strategy combined with weight decay and a warm-up mechanism; The defect analysis unit 230 is used to: calculate the cosine similarity between the feature vectors at the corresponding spatial locations for each scale's semantic feature map and reconstructed feature map; subtract the cosine similarity from 1 as the anomaly score for that spatial location at the current scale; summarize the anomaly scores at all scales and all spatial locations to form a multi-scale anomaly score map; fuse and post-process the multi-scale anomaly score map to generate the final defect location heatmap; apply threshold processing to the defect location heatmap, determine the areas with anomaly scores higher than a preset threshold as defect areas, and output the corresponding location information.

[0080] The technical solution of this embodiment, through a dual-branch collaborative architecture of a static guidance module and a dynamic reconstruction module, combined with image block random masking and multi-scale feature reconstruction mechanism, effectively enhances the model's adaptability to occlusion conditions and complex environments, significantly improves the identification sensitivity and localization accuracy of defect areas, and maintains good computational efficiency while ensuring high detection accuracy.

[0081] The parameters and steps for implementing the corresponding functions of each module in the robust industrial part surface defect detection system 200 of this embodiment can be referred to the parameters and steps in the embodiments of the robust industrial part surface defect detection method above, and will not be repeated here.

[0082] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A robust method for detecting surface defects in industrial parts, characterized in that, include: The system acquires input images of industrial parts and inputs these images into a statically guided module with frozen parameters to extract multi-scale semantic feature maps. The input image is segmented and randomly occluded to generate a sequence of image blocks with missing information. The image block sequence is then input into the dynamic reconstruction module for feature extraction and fusion to obtain the fused image feature representation. Multi-scale semantic reconstruction is performed on the image feature representation to generate a multi-scale reconstructed feature map corresponding to the multi-scale semantic feature map output by the static guidance module; Based on multi-scale semantic feature maps and multi-scale reconstructed feature maps, multi-scale anomaly scoring maps are calculated, and defective regions in the input image are identified and located according to the multi-scale anomaly scoring maps. The steps of performing multi-scale semantic reconstruction on image feature representations to generate a multi-scale reconstructed feature map corresponding to the multi-scale semantic feature map output by the static guidance module include: The image feature representation is input into the semantic-aware feature enhancement module to perform multi-scale context modeling and spatial axis dependency modeling, and the enhanced feature representation is output. The enhanced feature representation is input into the pyramid feature mapping module for upsampling and feature mapping to generate a multi-scale reconstructed feature map that is aligned with the static guidance module in terms of resolution and number of channels. The steps of inputting image feature representations into a semantically aware feature enhancement module, performing multi-scale context modeling and spatial axis dependency modeling, and outputting enhanced feature representations include: Local detail modeling is performed on the image feature representation, and initial detail features are obtained through a depthwise separable convolution operation of size 3×3; Multiple convolutional operations with different receptive fields are used in parallel to extract multi-scale contextual features; The initial detailed features are fused with multi-scale contextual features to generate a fused feature map; Global average pooling is performed on the image feature representation, and then mapped through a 1×1 convolutional layer. This is followed by two orthogonal stripe depthwise convolution operations with kernel sizes of [sizes to be filled in]. and To establish spatial axial dependencies and generate features Utilizing features Spatial weighting coefficients are generated using a 1×1 convolutional layer and a sigmoid activation function; The fused feature map is weighted using spatial weighting coefficients to output the enhanced feature representation; The formula for calculating the enhanced feature representation is: , , in, This represents the enhanced feature representation. Indicates features, This represents the fused feature map, Conv represents convolution, and DWConv represents depthwise separable convolution. This indicates the average pooling operation. and These represent strip-shaped depthwise convolutions in two orthogonal directions. It is a function used to ensure that the values ​​of attention weights are within the range of 0 to 1. This indicates element-wise multiplication.

2. The robust method for detecting surface defects in industrial parts according to claim 1, characterized in that, The steps for extracting multi-scale semantic feature maps include: Multi-scale semantic feature maps are obtained by extracting features from input images using a hierarchical encoder pre-trained on a large image dataset. The pre-trained hierarchical encoder is configured to abstract layer by layer, outputting at least three sets of feature maps with different spatial resolutions and semantic depths. The feature maps retain low-level detail information and high-level semantic information respectively from shallow to deep layers.

3. The robust method for detecting surface defects in industrial parts according to claim 1, characterized in that, The steps of segmenting the input image and performing random occlusion processing to generate a sequence of image patches with missing information, and then inputting the image patch sequence into the dynamic reconstruction module for feature extraction and fusion to obtain the fused image feature representation include: The input image is divided into multiple fixed-size image sub-blocks to obtain an initial image block sequence; With a preset occlusion ratio, some image sub-blocks in the initial image block sequence are randomly selected for occlusion, forming an image block sequence with partially missing information; For unoccluded image sub-blocks in a sequence of image blocks with missing information, the corresponding feature vectors are extracted using a dynamic reconstruction module. For occluded image sub-blocks, randomly initialized feature vectors are generated. All the processed feature vectors are concatenated according to their corresponding image sub-block spatial position order to generate the fused image feature representation.

4. The robust method for detecting surface defects in industrial parts according to claim 1, characterized in that, It also includes the step of training the dynamic reconstruction module, the training steps include: The dynamic reconstruction module is trained using only normal samples, with the training objective being to minimize the difference between its output multi-scale reconstruction feature map and the multi-scale semantic feature map extracted by the static guidance module. The training objective is achieved through a loss function, which is the sum of the average anomaly scores of all pixels on the anomaly scoring map at each scale. The training adopts a phased learning rate decay strategy and combines weight decay and warm-up mechanisms to optimize the dynamic reconstruction module.

5. The robust method for detecting surface defects in industrial parts according to claim 1, characterized in that, The steps of inputting the enhanced feature representation into the pyramid feature mapping module for upsampling and feature mapping to generate a multi-scale reconstructed feature map aligned with the static guidance module in terms of resolution and number of channels include: The enhanced feature representation is input as a high semantic feature map into the pyramid feature mapping module, and the high semantic feature map is upsampled step by step to obtain feature maps of different scales; The feature maps after each upsampling stage are sequentially subjected to channel mapping convolution, normalization, and smoothing convolution operations to generate the final multi-scale reconstructed feature map aligned with the features of the static guidance module.

6. The robust method for detecting surface defects in industrial parts according to claim 1, characterized in that, The steps for calculating a multi-scale anomaly scoring map based on multi-scale semantic feature maps and multi-scale reconstructed feature maps include: For each scale of semantic feature map and reconstructed feature map, calculate the cosine similarity between their feature vectors at the corresponding spatial locations; Subtracting the cosine similarity value from 1 gives the anomaly score for that spatial location at the current scale. Anomaly scores at all scales and in all spatial locations are aggregated to form a multi-scale anomaly score map.

7. The robust method for detecting surface defects in industrial parts according to claim 1, characterized in that, The steps for identifying and locating defect regions in an input image based on a multi-scale anomaly scoring map include: The multi-scale anomaly scoring maps are fused and post-processed to generate the final defect location heatmap. Threshold processing is applied to the defect location heatmap to identify areas with abnormal scores higher than a preset threshold as defect areas and output the corresponding location information.

8. A robust industrial part surface defect detection system, characterized in that, A robust method for detecting surface defects in industrial parts, as described in any one of claims 1-7, is adopted.

Citation Information

Patent Citations

  • Feature reconstruction model, training method and system thereof, medium and electronic equipment

    CN117830279A

  • Defect detection model training method, defect detection method, device and equipment

    CN120510154A