Complex curved surface product defect detection method and system based on semantic difference perception
Patent Information
- Application Number
- CN202410461419.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-17
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2044-04-17
AI Technical Summary
[0007]针对现有技术的不足,本发明拟解决的技术问题是,提出一种基于语义差异感知的复杂曲面产品缺陷检测方法及其系统
[0025] The spatial contrast and semantic difference-aware network of this invention can profoundly capture subtle differences in images, thereby accurately distinguishing defective and non-defective regions, and has advantages such as high accuracy, efficiency, and reliability. The CSC module first generates a segmentation mask representing a category, highlighting regions of a specific category while suppressing other non-critical regions. Furthermore, the CSC module further optimizes the intra-class compactness and inter-class separability of features through class-aware contrastive learning, enhancing the network's defect detection capability. The SDP module is used for semantic feature enhancement. It first obtains feature difference information by calculating the differences between low-level and high-level features extracted from different stages of the backbone network. Subsequently, a difference-aware loss function is introduced, which uses a normalized feature difference vector to guide the generation of channel attention weights, ensuring that the network not only focuses on regions with significant differences but also on regions with smaller differences, thereby capturing subtle semantic differences between the target and the background and establishing clear semantic boundaries, which is crucial for distinguishing certain similar classes or recognizing boundary details.
Smart Images

Figure CN118096724B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of product surface defect detection technology, specifically a method and system for detecting defects in complex curved surface products based on semantic difference perception. Background Technology
[0002] Aircraft engine blades are critical components of the engine. Even minor surface defects can lead to decreased engine performance, component damage, or even engine failure in severe cases. Therefore, defect detection is necessary, and the detection standards should reach absolute quality that exceeds inherent precision in order to maximize engine performance and efficiency while extending its service life.
[0003] Current inspection methods primarily rely on experienced inspectors' visual observation, supplemented by instruments such as coordinate measuring machines. While inspectors possess extensive experience, subjectivity can lead to inconsistent results and misjudgments. Manual inspection is labor-intensive, inefficient, and lacks the capability for high-precision quantitative analysis. Some research utilizes deep learning-based semantic segmentation models to segment defects in aero-engine blades, significantly reducing false positives caused by human factors and yielding more accurate and reliable results. However, even the most advanced semantic segmentation algorithms currently available still produce relatively coarse results and suffer from serious false detections. This is due to the following two challenges that surface defect detection still faces.
[0004] (1) Loss of detailed spatial features: Small defect areas have only a small spatial scale and a limited number of pixels, providing very limited spatial and gradient information. This makes it easy for the model to ignore these subtle feature information during feature extraction.
[0005] (2) Confusion of semantic features: Some defective regions in high-dimensional semantic space and their surrounding backgrounds are very similar in representation. Their color, texture and morphological features are highly consistent, which leads to some defects being regarded as part of the leaf itself, rather than as unique “objects” or “entities” that are clearly different from the background.
[0006] Therefore, this invention proposes a method and system for detecting defects in complex curved surface products based on semantic difference perception. By using a class-aware spatial comparison module and a semantic difference perception module, it effectively learns rich spatial detail representations and can capture subtle semantic differences between defects and the background, resulting in higher detection accuracy. Summary of the Invention
[0007] To address the shortcomings of existing technologies, the technical problem this invention aims to solve is to propose a method and system for detecting defects in complex curved surface products based on semantic difference perception.
[0008] The technical solution adopted by the present invention to solve the aforementioned technical problem is as follows:
[0009] A method for detecting defects in complex curved surface products based on semantic difference perception, characterized by the following steps:
[0010] Step 1: Obtain defective and non-defective images to obtain a dataset;
[0011] Step 2: Construct a spatial contrast and semantic difference perception network; The spatial contrast and semantic difference perception network uses the DeepLabV3 network as its basic framework. A CSC module is embedded between the second and third stages of the backbone network of the DeepLabV3 network. The output features of the CSC module and the output features of the last stage of the backbone network are input into the SDP module. The output features of the SDP module are concatenated with the output features of the ASPP module of the head network of the DeepLabV3 network. The concatenated features are then convolved and upsampled to obtain the output of the spatial contrast and semantic difference perception network.
[0012] For the CSC module, the input features are processed by a classifier to generate two segmentation masks, M0 and M1. The segmentation mask M0 is then multiplied element-wise with the input features of the CSC module to obtain the mask feature map F′0. The mask feature map F′0 is then subjected to both max pooling and average pooling to obtain the max-pooled feature F′. 0,max and average pooling feature F′ 0,avg Max pooling feature F′ 0,max Average pooling feature F′ 0,avg The segmentation mask M0 is concatenated along the channel dimension, then convolved and activated to obtain the attention weights A″0. The attention weights A″0 are then multiplied element-wise with the mask feature map F′0 to obtain the updated mask feature map F″0. Similarly, the segmentation mask M1 is multiplied element-wise with the input features of the CSC module to obtain the mask feature map F′1. The mask feature map F′1 is then subjected to max pooling and average pooling to obtain the max-pooled feature F′. 1,max and average pooling feature F′ 1,avg Max pooling feature F′ 1,max Average pooling feature F′ 1,avg The segmentation mask M1 is concatenated along the channel dimension and then subjected to convolution and activation operations to obtain the attention weight A″1. The attention weight A″1 is multiplied element-wise with the mask feature map F′1 to obtain the updated mask feature map F″1. The updated mask feature map F″0 is added to F″1 to obtain the output feature of the CSC module.
[0013] For the SDP module, the output features of the CSC module and the output features of the last stage of the backbone network are concatenated to obtain feature P; feature P is flattened and then convolved and activated to obtain channel attention weights; the channel attention weights are then multiplied pixel by pixel with feature P to obtain the output features of the SDP module.
[0014] Step 3: Use the dataset to train the spatial contrast and semantic difference perception network, and use the trained spatial contrast and semantic difference perception network as a defect detection model for defect detection of complex curved surface products.
[0015] Furthermore, the training loss is calculated based on the loss function in equation (3);
[0016] Loss=λ1L Seg1 +λ2L Seg2 +λ3L Seg3 +λ4L SDP (3)
[0017] In the formula, λ1~λ4 are constant coefficients, and L Seg1 L is the loss between the segmentation mask output by the classifier and the true label. Seg2 L is the loss between the output features of the last stage of the backbone network and the true label. Seg3 L represents the loss between the detection results of the spatial contrast and semantic difference perception network and the true label. SDP For difference perception loss;
[0018] Difference perception loss L SDP Defined as:
[0019] L SDP =||log(ω+∈)·log(1-b+∈)||2 (5)
[0020] In the formula, ω is the channel attention weight, ∈ is the adjustment parameter, and b is the normalized feature difference vector.
[0021] Furthermore, the output features of the CSC module and the output features of the last stage of the backbone network are upsampled and then subtracted pixel by pixel. After flattening, a feature difference vector is obtained. The feature difference vector is then normalized in the channel dimension to obtain a normalized feature difference vector.
[0022] The present invention also provides a defect detection system for complex curved surface products, including a processor, a memory and a computer program; the processor is connected to the memory, the computer program is stored in the memory, and the processor executes the computer program in the memory when the system is running.
[0023] Furthermore, the processor is a central processing unit (CPU), a digital signal processor (DSP), or a programmable gate array (FPGA); the memory is a read-only memory and a random access memory.
[0024] Compared with the prior art, the beneficial effects of the present invention are:
[0025] The spatial contrast and semantic difference-aware network of this invention can profoundly capture subtle differences in images, thereby accurately distinguishing defective and non-defective regions, and has advantages such as high accuracy, efficiency, and reliability. The CSC module first generates a segmentation mask representing a category, highlighting regions of a specific category while suppressing other non-critical regions. Furthermore, the CSC module further optimizes the intra-class compactness and inter-class separability of features through class-aware contrastive learning, enhancing the network's defect detection capability. The SDP module is used for semantic feature enhancement. It first obtains feature difference information by calculating the differences between low-level and high-level features extracted from different stages of the backbone network. Subsequently, a difference-aware loss function is introduced, which uses a normalized feature difference vector to guide the generation of channel attention weights, ensuring that the network not only focuses on regions with significant differences but also on regions with smaller differences, thereby capturing subtle semantic differences between the target and the background and establishing clear semantic boundaries, which is crucial for distinguishing certain similar classes or recognizing boundary details. Attached Figure Description
[0026] Figure 1 This is a structural diagram of the spatial contrast and semantic difference perception network of the present invention;
[0027] Figure 2 This is a structural diagram of the CSC module and SDP module of the present invention;
[0028] Figure 3 This is a visualization of the ablation experiment results of the present invention;
[0029] Figure 4 Visualize the defect detection results for different models. Detailed Implementation
[0030] Specific embodiments are given below with reference to the accompanying drawings. These specific embodiments are only used to illustrate the technical solutions of the present invention in detail, and are not intended to limit the scope of protection of this application.
[0031] This invention provides a method for detecting defects in complex curved surface products based on semantic difference perception (hereinafter referred to as the method, see below). Figures 1-4 The process includes the following steps:
[0032] Step 1: Obtain a dataset consisting of several product images, including defective and non-defective images;
[0033] This embodiment uses an aero-engine blade as an example. An aero-engine blade fault analysis system is used to construct a dataset containing 1500 images. Of these, 1000 are defect images, depicting defects such as dents, bends, pores, cracks, scratches, corrosion, wear, impact, and tearing; the remaining 500 are non-defect images. The dataset should include various blade types to reflect different performance requirements and application scenarios. The resolution of all images is standardized, using 512×512 pixels as a reference.
[0034] To ensure the accuracy of the dataset annotations, a multi-level verification mechanism is employed to guarantee the quality of each image label and ensure that the dataset meets high standards in terms of label consistency and accuracy. First, each image is independently annotated by two experienced leaf inspection experts, and then a third expert compares and reviews the annotations from the first two experts.
[0035] Step 2: Construct the Spatial Contrast and Semantic Difference Perception Network (SSPN). The SSPN uses the DeepLabV3 series network as its basic framework, embedding a Class-aware Spatial Contrast Module (CSC) and a Semantic Difference Perception Module (SDP) into the DeepLabV3 series network.
[0036] like Figure 1 As shown, the DeepLabV3Plus network includes a backbone network and a head network. The backbone network consists of four stages. A CSC module is embedded between the second and third stages of the backbone network. The output features of the CSC module and the output features of the last stage of the backbone network are used as the input features of the SDP module. The output features of the SDP module are concatenated with the output features of the ASPP module of the head network. The concatenated features are then convolved and upsampled to obtain the output of the spatial contrast and semantic difference perception network.
[0037] In the CSC module, the input feature F is processed by the classifier to generate two segmentation masks M0 and M1. The segmentation masks highlight the class regions in the input features and suppress other non-critical regions.
[0038] The segmentation mask M0 is element-wise multiplied with the input features F of the CSC module to obtain the mask feature map F′0. Since the mask feature map may be coarse and difficult to precisely locate class features, attention weights are generated using the mask feature map F′0 to highlight it. Specifically, the mask feature map F′0 is subjected to both max pooling and average pooling to obtain the max-pooled feature F′. 0,max and average pooling feature F′ 0,avg Max pooling feature F′ 0,max Average pooling feature F′ 0,avg The segmentation mask M0 is concatenated along the channel dimension, and then subjected to convolution and activation operations to obtain the attention weight A″0; the attention weight A″0 is multiplied element-wise with the mask feature map F′0 to obtain the updated mask feature map F″0.
[0039] Similarly, the segmentation mask M1 is multiplied element-wise with the input feature F of the CSC module to obtain the mask feature map F′1; the mask feature map F′1 is then subjected to max pooling and average pooling to obtain the max pooled feature F′. 1,max and average pooling feature F′ 1,avg Max pooling feature F′ 1,max Average pooling feature F′ 1,avg The segmentation mask M1 is concatenated along the channel dimension, and then subjected to convolution and activation operations to obtain the attention weight A″1. The attention weight A″1 is multiplied element-wise with the mask feature map F′1 to obtain the updated mask feature map F″1. The two updated mask feature maps F″0 and F″1 are added together to obtain the output feature of the CSC module.
[0040] The CSC module can be represented as:
[0041]
[0042] In the formula, c∈{0,1} represents the category, and C represents the classifier. This represents the Hadamard product, Maxpool represents the max pooling operation, Avgpool represents the average pooling operation, [;] represents concatenation of channel dimensions, and f 3×3 This represents a 3×3 convolution operation, and Sigm represents the Sigmoid activation operation.
[0043] In network architecture, low-level features may capture information such as edges, color, and texture, while high-level features may represent parts or the entire shape of an object. When low-level and high-level features are combined, they can provide a more comprehensive image representation. However, the information loss inherent in feature fusion may overlook many subtle feature differences, especially those existing between low-level and high-level features. Yet, these subtle differences are crucial for distinguishing certain similar classes or recognizing boundary details. Therefore, the SDP module is proposed to focus on the differential information between low-level and high-level features.
[0044] To obtain information about the differences between features, the output features of the CSC module are... The output features K of the last stage of the backbone network are used as inputs to the SDP module. Within the SDP module, the output features of the CSC module... The output feature K of the last stage of the backbone network is concatenated to obtain feature P; feature P is flattened and then convolved and activated to obtain channel attention weights ω; channel attention weights ω are then multiplied pixel by pixel with feature P to obtain the output feature G of the SDP module.
[0045] The SDP module can be represented as:
[0046]
[0047] In the formula, Upsample represents upsampling, GAP represents flattening operation, and f 1×1 This represents a convolution operation of size 1×1.
[0048] Step 3: Train the spatial contrast and semantic difference perception network, and use the trained spatial contrast and semantic difference perception network as a defect detection model for defect detection of complex curved surface products.
[0049] Considering that any defect in aero-engine blades can lead to serious consequences, and that the operating conditions of blades are extremely stringent, this embodiment divides the images in the dataset into two main categories: defective and non-defective. This helps the model better distinguish the health status of the blades. 800 defective images are randomly selected as the training set, which should include various defects. The remaining 200 defective and 500 non-defective images serve as the test set. Data augmentation can also be used to expand the dataset to further enhance the model's generalization ability and prevent overfitting. Data augmentation techniques include color dithering, Gaussian blur, random cropping, random horizontal flipping, and scaling.
[0050] During training, the batch size was set to 4, and a stochastic gradient descent (SGD) optimizer was used with a learning rate of 0.001 and a momentum of 0.9.
[0051] During training, the training loss is calculated using the loss function in equation (3);
[0052] Loss=λ1L Seg1 +λ2L Seg2 +λ3L Seg3 +λ4L SDP (3)
[0053] In the formula, λ1 to λ4 are constant coefficients. In this embodiment, λ1 ≡ 0.5, λ2 = 0.5, λ3 = 1, and λ4 = 0.01; L Seg1 L is the loss between the segmentation mask output by the classifier and the true label. Seg2 L is the loss between the output features of the last stage of the backbone network and the true label. Seg3 L represents the loss between the detection results of the spatial contrast and semantic difference perception network and the true label. Seg1 L Seg2 and L Seg3 All were calculated using the Dice Loss function; L SDP This is the loss of perceived difference.
[0054] Output characteristics of the CSC module The features obtained by upsampling the output features K of the last stage of the backbone network are subtracted pixel by pixel and then flattened to obtain the feature difference vector D. The feature difference vector D is normalized in the channel dimension to obtain the normalized feature difference vector b.
[0055]
[0056] In the formula, Max and Min represent the maximum and minimum values in the channel dimension, respectively, and b = {b1, b2, ..., b} j In b, each element represents the difference factor for the corresponding channel. j b represents the difference factor of channel j. j The larger the value, the greater the characteristic difference of channel j;
[0057] To capture subtle semantic differences between the target and the background and establish clear semantic boundaries, a normalized feature difference vector *b* is used to guide the recalibration of the channel attention weights *ω*. *b* represents large differences between features, while *1-b* represents small differences. Since there is a positive correlation between the channel attention weights *ω* and *1-b*, this ensures that the network pays attention not only to the high values in the normalized feature difference vector *b* but also to its low values. This helps prevent the network from over-focusing on certain feature regions, resulting in a more balanced feature representation. Therefore, the difference-perceived loss L... SDP Defined as:
[0058] L SDP=||log(ω+∈)·log(1-b+∈)||2 (5)
[0059] In the formula, ∈ is an adjustment parameter, which is generally taken as 10. -5 ~10 -4 Its purpose is to prevent ω or 1-b from being equal to zero.
[0060] This invention also provides a defect detection system for complex curved surface products, including a processor, a memory, and a computer program. The processor is connected to the memory, and the computer program is stored in the memory. When the system runs, the processor executes the computer program in the memory, causing the system to perform the aforementioned method. The processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), programmable gate arrays (FPGAs), etc. The memory can be a read-only memory (ROM) or a random access memory (RAM), providing instructions and data to the processor. In implementation, each step of the aforementioned method can be completed through integrated logic circuits in the processor or through software instructions.
[0061] To verify the effectiveness of the CSC and SDP modules, an ablation experiment was conducted on the two modules using DeepLabV3Plus as the baseline model for aero-engine blade defect detection. The impact of different modules on the performance of the baseline model was observed. The detection performance is shown in Table 1, and the visualization results are as follows. Figure 3 As shown.
[0062] Table 1 Ablation Experiment Results of CSC and SDP Modules
[0063] Baseline model × × 89.74 +CSC √ × 92.15 +SDP × √ 92.20 +SDP+CSC √ √ 93.42
[0064] As shown in Table 1, adding the CSC module or the SDP module to the baseline model improved performance by 2.41% and 2.46%, respectively, indicating that both CSC and SDP modules have a positive direct effect on the performance of the baseline model. Furthermore, adding both CSC and SDP modules simultaneously improved the performance of the baseline model by 3.69%, further demonstrating that CSC and SDP modules can improve model performance, and that using them together can produce a synergistic effect.
[0065] This invention uses the CSC module to address the problem of spatial feature loss in small or highly detailed damaged areas. As shown in Table 1, compared to the baseline model, adding the CSC module to the baseline model improves the model performance for aero-engine blade defect detection by 2.41%. Figure 3As can be seen, compared with the baseline model, the addition of the CSC module allows the model to better capture spatial features when dealing with small or highly detailed damaged areas, avoiding the problem of spatial feature loss. This phenomenon proves that the CSC module effectively establishes clear and detailed spatial boundaries and effectively highlights and distinguishes background and damaged features. Furthermore, the CSC module enhances the model's sensitivity to detailed damaged features and improves its understanding of the overall scene, enabling the model to achieve high-precision, high-quality defect detection in various complex environments.
[0066] Introducing the SDP module into the baseline model improved model performance by 2.46%. Figure 3 The detection results show that the SDP module effectively solves the problems of false detection and false recognition, enhancing the model's semantic discrimination ability. The core idea of the SDP module is to capture and utilize subtle semantic differences to generate more balanced and contrastive feature representations, enhancing the model's focus on low-discrepancy regions. This allows for more accurate identification of actual damaged areas and avoids false recognition in undamaged regions. This capability is crucial for ensuring the reliability and accuracy of the model, especially in highly sensitive scenarios.
[0067] In summary, by introducing both the SDP and CSC modules into the baseline model, this invention demonstrates a 3.68% improvement in overall performance mIOU. This significant improvement proves the benefits of SDP and CSC, and their synergistic effect when used together.
[0068] To verify the effectiveness of the defect detection model of this invention, it was compared with several existing advanced semantic segmentation methods for defect detection in aero-engine blades. The detection performance of different models is shown in Table 2, and the visualization results are as follows. Figure 4 As shown.
[0069] Table 2 Comparison of detection results of different models
[0070]
[0071]
[0072] As shown in Table 2, compared with other models, the defect detection model of the present invention has excellent performance, with an mIOU of 93.42%, which is significantly greater than other models.
[0073] References:
[0074] [1]L.-C.Chen,Y.Zhu,G.Papandreou,F.Schroff,and H.Adam,“Encoder-decoderwith atrous separable convolution for semantic image segmentation,”inProceedings of the European conference on computer vision(ECCV),2018,pp.801–818.
[0075] [2]J.Fu,J.Liu,J.Jiang,Y.Li,Y.Bao,and H.Lu,“Scene segmentation withdual relation-aware attention network,”IEEE Transactions on Neural Networksand Learning Systems,vol.32,no.6,pp.2547–2560,2020.
[0076] [3]L.Huang,Y.Yuan,J.Guo,C.Zhang,X.Chen,and J.Wang,“Interlaced sparseself-attention for semantic segmentation,”arXiv preprint arXiv:1907.12273,2019.
[0077] [4]T.Wu,S.Tang,R.Zhang,J.Cao,and Y.Zhang,“Cgnet:A lightweight contextguided network for semantic segmentation,”IEEE Transactions on ImageProcessing,vol.30,pp.1169–1179,2020.
[0078] [5]A.Kirillov,Y.Wu,K.He,and R.Girshick,“Pointrend:Image segmentationas rendering,”in Proceedings of the IEEE / CVF conference on computer visionand pattern recognition,2020,pp.9799–9808.
[0079] [6]C.Yu,C.Gao,J.Wang,G.Yu,C.Shen,and N.Sang,“Bisenet v2:Bilateralnetwork with guided aggregation for real-time semantic segmentation,”International Journal of Computer Vision,pp.1–18,2021.
[0080] [7]R.Ranftl,A.Bochkovskiy,and V.Koltun,“Vision transformers for denseprediction,”in Proceedings of the IEEE / CVF international conference oncomputer vision,2021,pp.12 179–12188.
[0081] [8]M.Fan,S.Lai,J.Huang,X.Wei,Z.Chai,J.Luo,and X.Wei,“Rethinkingbisenet for real-time semantic segmentation,”in Proceedings of the IEEE / CVFConference on Computer Vision and Pattern Recognition,2021,pp.9716–9725.
[0082] [9] Y. Hong, H. Pan, W. Sun, and Y. Jia, "Deep dual-resolution networks for real-time and accurate semantic segmentation of road scenes," arXiv preprint arXiv:2101.06085, 2021.
[0083]
[10] W. Yu, M. Luo, P. Zhou, C. Si, Y. Zhou, X. Wang, J. Feng, and S. Yan, "Metaformer is actually what you need for vision," in Proceedings of the IEEE / CVF Conference on Computer Vision and Pattern Recognition, 2022, pp. 10 819–10 829.
[0084]
[11] B. Cheng, I. Misra, A. G. Schwing, A. Kirillov, and R. Girdhar, "Masked-attention mask transformer for universal image segmentation," in Proceedings of the IEEE / CVF conference on computer vision and pattern recognition, 2022, pp. 1290–1299.
[0085]
[12] J. Xu, Z. Xiong, and S. P. Bhattacharyya, "Pidnet: A real-time semantic segmentation network inspired by pid controllers," in Proceedings of the IEEE / CVF Conference on Computer Vision and Pattern Recognition, 2023, pp. 19 529–19 539.
[0086] Subject matters not mentioned in the present invention are applicable to the prior art.
Claims
1. A method for detecting defects in complex curved surface products based on semantic difference perception, characterized in that, The method includes the following steps: Step 1: Obtain defective and non-defective images to obtain a dataset; Step 2: Construct a spatial contrast and semantic difference perception network; The spatial contrast and semantic difference perception network uses the DeepLabV3 network as its basic framework. A CSC module is embedded between the second and third stages of the backbone network of the DeepLabV3 network. The output features of the CSC module and the output features of the last stage of the backbone network are input into the SDP module. The output features of the SDP module are concatenated with the output features of the ASPP module of the head network of the DeepLabV3 network. The concatenated features are then convolved and upsampled to obtain the output of the spatial contrast and semantic difference perception network. For the CSC module, the input features are processed by a classifier to generate two segmentation masks, M0 and M1. The segmentation mask M0 is then multiplied element-wise with the input features of the CSC module to obtain the mask feature map F′0. The mask feature map F′0 is then subjected to both max pooling and average pooling to obtain the max-pooled feature F′. 0,max and average pooling feature F′ 0,avg Max pooling feature F′ 0,max Average pooling feature F′ 0,avg The segmentation mask M0 is concatenated along the channel dimension, then convolved and activated to obtain the attention weights A″0. The attention weights A″0 are then multiplied element-wise with the mask feature map F′0 to obtain the updated mask feature map F″0. Similarly, the segmentation mask M1 is multiplied element-wise with the input features of the CSC module to obtain the mask feature map F′1. The mask feature map F′1 is then subjected to max pooling and average pooling to obtain the max-pooled feature F′. 1,max and average pooling feature F′ 1,avg Max pooling feature F′ 1,max Average pooling feature F′ 1,avg The segmentation mask M1 is concatenated along the channel dimension and then subjected to convolution and activation operations to obtain the attention weight A″1. The attention weight A″1 is multiplied element-wise with the mask feature map F′1 to obtain the updated mask feature map F″1. The updated mask feature map F″0 is added to F″1 to obtain the output feature of the CSC module. For the SDP module, the output features of the CSC module and the output features of the last stage of the backbone network are concatenated to obtain feature P; feature P is flattened and then convolved and activated to obtain channel attention weights; the channel attention weights are then multiplied pixel by pixel with feature P to obtain the output features of the SDP module. Step 3: Use the dataset to train the spatial contrast and semantic difference perception network, and use the trained spatial contrast and semantic difference perception network as a defect detection model for defect detection of complex curved surface products.
2. The method for detecting defects in complex curved surface products based on semantic difference perception according to claim 1, characterized in that, The training loss is calculated based on the loss function in equation (3); Loss=λ1L Seg1 +λ2L Seg2 +λ3L Seg3 +λ4L SDP (3) In the formula, λ1~λ4 are constant coefficients, and L Seg1 L is the loss between the segmentation mask output by the classifier and the true label. Seg2 L is the loss between the output features of the last stage of the backbone network and the true label. Seg3 L represents the loss between the detection results of the spatial contrast and semantic difference perception network and the true label. SDP For difference perception loss; Difference perception loss L SDP Defined as: L SDP =||log(ω+∈)·log(1-b+∈)||2 (5) In the formula, ω is the channel attention weight, ∈ is the adjustment parameter, and b is the normalized feature difference vector.
3. The method for detecting defects in complex curved surface products based on semantic difference perception according to claim 2, characterized in that, The output features of the CSC module and the output features of the last stage of the backbone network are upsampled and then subtracted pixel by pixel. After flattening, the feature difference vector is obtained. The feature difference vector is normalized along the channel dimension to obtain the normalized feature difference vector.
4. The method for detecting defects in complex curved surface products based on semantic difference perception according to any one of claims 1 to 3, characterized in that, The defects include dents, bends, pores, cracks, scratches, corrosion, wear, impacts, and tears.
5. A defect detection system for complex curved surface products using the method described in claim 1, characterized in that, The system includes a processor, a memory, and a computer program; the processor is connected to the memory, the computer program is stored in the memory, and the processor executes the computer program in the memory when the system is running.
6. The defect detection system for complex curved surface products according to claim 5, characterized in that, The processor is a central processing unit (CPU), a digital signal processor (DSP), or a programmable gate array (FPGA); the memory is a read-only memory and a random access memory.