A method, system, computer readable storage medium and computer program product for seal pin defect detection based on improved graph attention mechanism

By constructing a semantic segmentation network using an improved graph attention mechanism, the problems of poor generalization performance and difficulty in identifying small-sized defects in sealing nail defect detection are solved, achieving higher detection accuracy.

CN119048449BActive Publication Date: 2026-11-24GUANGDONG AOPUTE TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411095112.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2026-11-24
Estimated Expiration
2044-08-09

AI Technical Summary

Technical Problem

Existing sealing nail defect detection algorithms have poor generalization performance when detecting multiple types of defects, making it difficult to effectively identify small-sized defects. Furthermore, traditional deep learning methods cannot be directly applied to point cloud data, resulting in low detection accuracy.

Method used

An improved graph attention mechanism is adopted. By constructing a semantic segmentation network, local features are aggregated using vector attention operators to generate a correlation coefficient matrix. The attention weight matrix is ​​constrained according to the spatial distance relationship, and combined with normal vector feature encoding, the segmentation accuracy of defect regions is improved.

Benefits of technology

It improves the accuracy of sealing nail defect detection, can identify potential defects that traditional algorithms cannot identify, and enhances the detection capability for small-sized defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119048449B_ABST
    Figure CN119048449B_ABST
Patent Text Reader

Abstract

This invention relates to the field of defect detection technology, and discloses a method, system, computer-readable storage medium, and computer program product for detecting sealing nail defects based on an improved graph attention mechanism. The method includes: constructing a semantic segmentation network for segmenting defect regions; aggregating local features using vector attention operators to generate a correlation coefficient matrix, and constraining the correlation coefficient matrix according to spatial distance relationships to obtain the attention weight matrix of the semantic segmentation network; adding normal vector feature encoding to the edge convolution operation process to obtain the edge convolution operator of the semantic segmentation network; constructing a semantic segmentation model based on the semantic segmentation network, and training the semantic segmentation model using a pre-constructed sealing nail defect training set to obtain the network parameters of the semantic segmentation model. The semantic segmentation model of this invention can accurately segment defect regions and identify potential defects that traditional algorithms cannot identify, effectively improving the accuracy of defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of defect detection technology, and in particular to a method, system, computer-readable storage medium, and computer program product for detecting sealing nail defects based on an improved graph attention mechanism. Background Technology

[0002] Existing methods for detecting sealing nail defects using traditional algorithms rely on variable criteria for defect identification, requiring frequent parameter adjustments based on working conditions and actual production needs. This poses significant challenges for machine vision inspection algorithms when detecting and classifying multiple types of defects. For example, Chinese patent application number "202211166623.7," entitled "A Method and System for Detecting Sealing Nail Defects," proposes a sealing nail defect detection algorithm based on a combination of YOLOv5 and 3D point clouds. However, when updating the detection model for a specific type of defect, this patented technology affects the accuracy of the model in detecting other types of defects, resulting in low accuracy in detecting sealing nail welding defects. Therefore, existing algorithms exhibit poor generalization performance, limiting the deployment and application of machine vision inspection methods.

[0003] Currently, the following problems exist in the defect detection of sealing nails during actual production: (1) During the sealing process of the sealing nail, the probability of defective products is low due to the improvement of the processing technology; this results in a small number of missing sealing nail samples, making it difficult to collect large-scale data. (2) The existing defects of various sealing nails vary greatly in size, and some defects are small in size. A few defect detection methods that use 2D images alone, such as the Chinese patent with application number "202310581810.X" and title "Detection method of sealing nail welding defects, storage medium and electronic device", may miss small-sized defects. (3) In order to achieve high-precision detection, the detection process collects point cloud data of the sealing nail, but the current classic deep learning methods cannot be directly applied to non-Euclidean data such as point clouds.

[0004] Therefore, how to extract useful features from point cloud pairs with indistinct geometric features or low overlap and construct effective correspondences has become a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] The purpose of this invention is to provide a method, system, computer-readable storage medium, and computer program product for detecting sealing nail defects based on an improved graph attention mechanism, so as to solve or at least partially solve the technical problems mentioned in the background art.

[0006] To achieve this objective, the present invention adopts the following technical solution: In a first aspect, the present invention provides a method for detecting sealing nail defects based on an improved graph attention mechanism, comprising: Construct a semantic segmentation network for segmenting defective regions; The vector attention operator is used to aggregate local features to generate a correlation coefficient matrix. The correlation coefficient matrix is ​​then constrained according to spatial distance relationships to obtain the attention weight matrix of the semantic segmentation network. Add normal vector feature encoding to the edge convolution operation process to obtain the edge convolution operator of the semantic segmentation network; A semantic segmentation model is constructed based on the semantic segmentation network, and the semantic segmentation model is trained using a pre-built training set of sealing nail defects to obtain the network parameters of the semantic segmentation model. Use a trained semantic segmentation model to detect or identify defects in sealing nails.

[0007] Optionally, before aggregating local features using the vector attention operator to generate a correlation coefficient matrix, and constraining the correlation coefficient matrix according to spatial distance relationships to obtain the attention weight matrix of the semantic segmentation network, the method further includes: Construct a graph structure for the point cloud data of the sealing nail; specifically including: Construct a directed graph To represent the local features of point cloud data; With each Using the center point as the basis, and based on the relative positions of the points, Construct a k-nearest neighbor graph of type X; in, It is a set of vertices. X is the set of edges, k is the k value of the k-nearest neighbor algorithm, and X is the set of point features in the point cloud data.

[0008] Optionally, the step of aggregating local features using a vector attention operator to generate a correlation coefficient matrix, and constraining the correlation coefficient matrix according to spatial distance relationships to obtain the attention weight matrix of the semantic segmentation network, specifically includes: Based on the k-nearest neighbor graph, the center point and its adjacent neighboring points Characteristic differences ( Using this as input, a correlation coefficient matrix is ​​generated using subtraction; the correlation coefficient matrix is ​​calculated as follows: ,in, and It consists of two independent linear layers; Constraining the correlation coefficient matrix based on spatial distance relationships yields the attention weight matrix for the semantic segmentation network. The spatial distance relationship expression is as follows: , for spatial coordinates, for Spatial coordinates; The attention weight matrix of the semantic segmentation network is calculated as follows: .

[0009] Optionally, the step of adding normal vector feature encoding to the edge convolution operation process to obtain the edge convolution operator of the semantic segmentation network specifically includes: The parameters of the convolution kernel in the graph convolution module are designed, and the edge kernel operator of the graph convolution module is calculated. The calculation formula for the edge kernel operator is as follows: , and These are the parameters of the convolution kernel; Add normal vector feature encoding to the edge core operator; update the calculation formula of the edge core operator to... ; in, Let be a nonlinear function, where and The center point and neighboring points The normal vector.

[0010] Optionally, the step of constructing a semantic segmentation model based on the semantic segmentation network and training the semantic segmentation model using a pre-built training set of sealing nail defects to obtain the network parameters of the semantic segmentation model specifically includes: Adjust the model training parameters according to the defect size in the sealing nail defect training set; The semantic segmentation model was trained using the sealing nail defect training set, and the most suitable network parameters were obtained through multiple training sessions as the network parameters of the semantic segmentation model.

[0011] Optionally, adjusting the model training parameters according to the defect size in the sealing nail defect training set includes: For training samples with small defect sizes in the sealing nail defect training set, weights based on the label proportion are added to the loss function; the loss function... Expressed as: , ; Where C is the number of categories. This is the prediction result output by the network, where y is the label and w is the prediction result. c It represents the label weights; N is the total number of points in the dataset, n c It is the total number of points of one class in the dataset.

[0012] Optionally, before constructing the graph structure from the point cloud data of the sealing nail, the method further includes: Multiple sealing nail point cloud data are collected and labeled to construct the datasets required for training and testing; the datasets required for training and testing include a sealing nail defect training set and a sealing nail defect detection test set; Before using the trained semantic segmentation model to detect or identify defects in the sealing nail, the method further includes: The trained semantic segmentation model is tested using a sealing nail defect detection test set. The test results are stored in the form of txt text and visualized using point cloud rendering.

[0013] Optionally, the step of collecting and labeling multiple sealing nail point cloud data to construct the dataset required for training and testing specifically includes: Point cloud data of two types of sealing nails, flat nails and concave nails, were collected using a 3D line scan camera; The welding area of ​​the point cloud data of the concave nail was segmented using the RANSAC algorithm to obtain data samples; Data augmentation is performed on the weld area samples to expand the number of data samples and form a dataset; Use annotation tools to label the data samples in the dataset to build the dataset needed for training and testing.

[0014] Optionally, the construction of the semantic segmentation network for segmenting defective regions specifically includes: Based on the 2D image semantic segmentation network U-Net, a semantic segmentation network for segmenting defective regions is constructed. The semantic segmentation network is an encoder-decoder structure, including: a graph attention module, a downsampling module, a graph convolution module, and an upsampling module; The graph attention module is the core feature extraction structure used to encode the input features; the graph convolution module in the decoding layer can add normal vector feature encoding of points to enhance the features extracted by the encoding layer.

[0015] Secondly, the present invention provides a system for detecting sealing nail defects based on an improved graph attention mechanism, comprising: The network architecture module is used to build a semantic segmentation network for segmenting defective regions; The data processing module, electrically connected to the network architecture module, is used to aggregate local features using vector attention operators, generate a correlation coefficient matrix, and constrain the correlation coefficient matrix according to spatial distance relationships to obtain the attention weight matrix of the semantic segmentation network; it is also used to add normal vector feature encoding to the edge convolution operation process to obtain the edge convolution operator of the semantic segmentation network. The model training module is electrically connected to the data processing module and is used to construct a semantic segmentation model based on the semantic segmentation network, and to train the semantic segmentation model using a pre-constructed training set of sealing nail defects to obtain the network parameters of the semantic segmentation model. The defect detection terminal is electrically connected to the model training module and is used to detect or identify defects in the sealing nail using the trained semantic segmentation model.

[0016] Thirdly, the present invention provides a computer-readable storage medium storing at least one instruction, characterized in that the instruction is loaded and executed by a processor to implement a method for detecting sealing nail defects based on an improved graph attention mechanism as described above.

[0017] Fourthly, the present invention provides a computer program product, including a computer program / instruction, characterized in that, when the computer program / instruction is executed by a processor, it implements a method for detecting sealing nail defects based on an improved graph attention mechanism as described above.

[0018] Compared with the prior art, the beneficial effects of the present invention are as follows: The semantic segmentation network used in this invention generates the correlation coefficient matrix using a subtraction relationship instead of a multiplication relationship, and uses spatial distance relationships to constrain the correlation coefficient matrix, which can better capture the local geometric relationships of point clouds and accurately segment defect regions. By adding normal vector feature encoding to the edge convolution operation process, the deviation between the normal vectors of adjacent points is captured, which can identify potential defects that traditional algorithms cannot identify, effectively improving the accuracy of defect detection. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a flowchart of a method for detecting sealing nail defects based on an improved graph attention mechanism, provided as an embodiment of the present invention.

[0021] Figure 2 This is a schematic diagram of the architecture of a system for detecting sealing nail defects based on an improved graph attention mechanism, provided in an embodiment of the present invention.

[0022] In the picture: 10. Network architecture module; 20. Data processing module; 30. Model training module; 40. Defect detection terminal. Detailed Implementation

[0023] To make the objectives, features, and advantages of this invention more apparent and understandable, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0024] Example 1: Please refer to Figure 1 , Figure 1 A flowchart of a method for detecting sealing nail defects based on an improved graph attention mechanism is provided in this embodiment of the invention. The method specifically includes: Step 110: Construct a semantic segmentation network for segmenting defective regions. Specifically: Based on the 2D image semantic segmentation network U-Net, a semantic segmentation network for segmenting defective regions is constructed. The semantic segmentation network has an encoder-decoder structure, including: a graph attention module, a downsampling module, a graph convolution module, and an upsampling module; The graph attention module is the core feature extraction structure used to encode the input features; the graph convolution module in the decoding layer can add normal vector feature encoding of points to enhance the features extracted by the encoding layer.

[0025] It should be noted that the U-Net network is a paper published by Ronneberger et al. in 2015 in MICCAI, a top journal in computer medical imaging. The paper is titled "U-Net: Convolutional Networks for Biomedical Image Segmentation". This paper first proposed a U-shaped structure for semantic segmentation of images. For details on the principle, please refer to the original paper, which will not be repeated here.

[0026] Before step 110, there is also a preset step 101.

[0027] Step 101: Construct a graph structure for the point cloud data of the sealing nail; specifically including: Construct a directed graph To represent the local features of point cloud data; With each Using the center point as the basis, and based on the relative positions of the points, Construct a k-nearest neighbor graph of type X; In step 101, It is a set of vertices. X is the set of edges, k is the k value of the k-nearest neighbor algorithm, and X is the set of point features in the point cloud data.

[0028] The method for acquiring point cloud data in step 101 is as follows: Collect and label multiple sealing nail point cloud data to construct the dataset required for training and testing; Point cloud data of two types of sealing nails, flat nails and concave nails, were collected using a 3D line scan camera; The welding area of ​​the point cloud data of the concave nail was segmented using the RANSAC algorithm to obtain data samples; Data augmentation is performed on the weld area samples to expand the number of data samples and form a dataset; Use annotation tools to label the data samples in the dataset to build the dataset needed for training and testing.

[0029] In this embodiment, the datasets required for training and testing include a dataset for training on sealing nail defects and a dataset for testing on sealing nail defects. For ease of description, the dataset for training on sealing nail defects is defined as the sealing nail defect training set, and the dataset for testing on sealing nail defects is defined as the sealing nail defect detection test set.

[0030] Understandably, each dataset should contain multiple different datasets. For example, a training set for sealing nail defects should include point cloud data of various defects that may occur in actual production. This is because when the dataset is rich enough, the defect identification accuracy of the model trained on it will be higher.

[0031] Step 120: Aggregate local features using the vector attention operator to generate a correlation coefficient matrix, and constrain the correlation coefficient matrix according to the spatial distance relationship to obtain the attention weight matrix of the semantic segmentation network.

[0032] Step 120 specifically includes: Based on the k-nearest neighbor graph, the center point and its adjacent neighboring points Characteristic differences ( Using this as input, a correlation coefficient matrix is ​​generated using subtraction; the correlation coefficient matrix is ​​calculated as follows: ,in, and It consists of two independent linear layers; Constraining the correlation coefficient matrix based on spatial distance relationships yields the attention weight matrix for the semantic segmentation network. The spatial distance relationship expression is as follows: , for spatial coordinates, for Spatial coordinates; The attention weight matrix of a semantic segmentation network is calculated as follows: .

[0033] In this step, what is the K-Nearest Neighbor algorithm, or KNN algorithm for short? It means that, given a training dataset, for a new input instance, find the K nearest neighbors to the current instance in the training dataset. If the majority of these K instances belong to a certain class, then the input instance is classified into that class. When it is impossible to determine which category the current point to be classified belongs to from the known categories, we can use statistical theory to look at its location characteristics, measure the weight of its surrounding neighbors, and classify or assign it to the category with the greater weight.

[0034] In this step, a vector attention operator is used to aggregate local features, a subtraction relationship is used instead of a multiplication relationship to generate the correlation coefficient matrix, and the correlation coefficient matrix is ​​constrained according to spatial distance relationships. Finally, the attention matrix is ​​generated through Softmax activation. Here, Softmax is the activation function.

[0035] In this step, the linear layer is a basic layer in a neural network. Each node in this layer is connected to every node in the previous layer, and each connection has a weight used to adjust the influence of the input data. Linear layers help the network better understand the input data and are often used alternately with non-linear activation functions (such as ReLU) to form the basic building blocks of a neural network.

[0036] Step 130: Add normal vector feature encoding to the edge convolution operation process to obtain the edge convolution operator of the semantic segmentation network. Specifically, this includes: The parameters of the convolution kernel in the graph convolution module are designed, and the edge kernel operator of the graph convolution module is calculated. The calculation formula for the edge kernel operator is as follows: , and These are the parameters of the convolution kernel; Add normal vector feature encoding to the edge core operator; update the calculation formula of the edge core operator to... ; in, Let be a nonlinear function, where and The center point and neighboring points The normal vector.

[0037] This step uses a multilayer perceptron (MLP), followed by max pooling to aggregate the edge features extracted by the edge convolution. Unlike other semantic segmentation tasks, in the sealing nail defect detection task, the normal vectors of the defective regions to be segmented vary significantly. Ideally, the normal vectors of the deepest points in both the defect-free and defective regions are typically perpendicular to the XZ plane. By capturing the deviation between adjacent normal vectors, potential defects can be identified. Therefore, adding normal vector feature encoding to the edge convolution operation process can extract local geometric information more efficiently.

[0038] It is understandable that there are many non-linear activation functions in MLP, which can be selected according to different application requirements. For example, the non-linear activation function selected in this embodiment is ReLU, which has the following advantages: (1) The calculation is relatively simple; it only requires setting negative values ​​in the input to zero while keeping positive values ​​unchanged. This is faster than activation functions that involve complex calculations (such as sigmoid and tanh). (2) Unlike sigmoid and tanh, ReLU does not perform exponential operations during the calculation process, so it converges faster. (3) ReLU can effectively alleviate the gradient vanishing problem; (4) Since ReLU will output zero for all negative inputs, it can produce sparse activation (i.e., some neurons remain inactive at the same time). Sparse activation can improve the efficiency and generalization ability of the network and alleviate overfitting.

[0039] In this embodiment, max pooling is a commonly used downsampling technique in convolutional neural networks. Its main function is to retain the most important features by selecting the maximum value in a local region, while reducing the dimensionality of the data and the amount of computation. This technique helps improve the robustness and generalization ability of the model, making the model less sensitive to small changes in input. During processing, the max pooling layer selects the maximum value in each local region of the input feature map as the output value. This process is similar to a sliding window moving across the input data and selecting the maximum value at each position. Max pooling is used to reduce the spatial size of the data while maintaining the saliency of the features, improving the efficiency and performance of the entire network by simplifying data representation and reducing computational complexity.

[0040] In this embodiment, the basic network architecture of the semantic segmentation model is constructed with reference to the 2D image semantic segmentation network U-Net, which is a typical encoder-decoder structure. The network includes a graph attention module, a downsampling module, a graph convolution module, and an upsampling module. Among them, the core feature extraction structure is the graph attention module, which encodes the input features. Then, the normal vector features of the additional points are encoded for the graph convolution module in the decoding layer, which strengthens the features extracted by the encoding layer and improves the network's ability to extract local geometric information.

[0041] Step 140: Construct a semantic segmentation model based on the semantic segmentation network, and train the semantic segmentation model using a pre-built training set of sealing nail defects to obtain the network parameters of the semantic segmentation model. Step 140 specifically includes: Adjust the model training parameters according to the defect size in the sealing nail defect training set; The semantic segmentation model was trained using the sealing nail defect training set, and the most suitable network parameters were obtained through multiple training sessions as the network parameters of the semantic segmentation model.

[0042] Based on the defect size in the sealing nail defect training set, adjust the model training parameters accordingly, including: For training samples with small defect sizes in the sealing nail defect training set, weights based on the label proportion are added to the loss function; the loss function... Used to measure the difference between predicted and actual results, in this embodiment... Expressed as: , ; Where C is the number of categories. This is the prediction result output by the network, where y is the label and w is the prediction result. c It represents the label weights; N is the total number of points in the dataset, n c It is the total number of points of one class in the dataset.

[0043] After improvements in steps 120 and 130, the semantic segmentation network constructed in step 110 is used to train the new model using a pre-built training set, and the training parameters are adjusted. For issues with small defect sizes, label weights are added to the loss function. Multiple training iterations are performed to find suitable network parameters, optimizing the model's performance.

[0044] It should be noted that, since the defect area in the sealing nail dataset is very small, in step 140, a weighted network needs to be added to the loss function. Otherwise, during training, the network will tend to predict all points as having no defects in order to reduce the loss, which will cause the network to fail to converge.

[0045] Step 150: Test the trained semantic segmentation model using the sealing nail defect detection test set, save the test results in the form of txt text, and use point cloud rendering to visualize the test results.

[0046] The model trained in step 140 is used to test the sealing nail defect detection test set; the recognition results are saved in the form of txt text and can be visualized using point cloud rendering software.

[0047] In this step, testing is used to determine whether the trained semantic segmentation model has achieved the expected goal. The sampling visualization is to make it easier for staff to visually inspect the test situation and results.

[0048] Step 160: Determine whether the accuracy of defect detection based on the semantic segmentation model has reached the expected level based on the test results; if yes, proceed to step 170; if no, proceed to step 180.

[0049] Step 170: Use the trained semantic segmentation model to detect or identify defects in the sealing nail.

[0050] After testing the trained semantic segmentation model using a sealing nail defect detection test set, the accuracy of defect detection can be used to determine whether the training of the semantic segmentation model has achieved the expected results. Table 1 below shows the defect detection algorithm of this embodiment and compares its recognition results with several other defect detection algorithms based on the same scene: Table 1 As can be seen from Table 1, the semantic segmentation network used in this embodiment has higher recognition accuracy, can accurately segment defect areas, and effectively improve the accuracy of defect detection.

[0051] Step 180: Reconstruct the training set of sealing nail defects based on the test results.

[0052] When the training effect is not good, it indicates that there are omissions in the construction of the training set or that the training amount is insufficient. At this time, it is necessary to further enrich the training set. For example, defective content that cannot be identified or is misidentified in the test set can be added to the training set, and the samples can be further data augmented; then the semantic segmentation model can continue to be trained.

[0053] Understandably, neural networks make predictions or classifications by learning patterns and regularities in data. During the training phase, the network receives input data, calculates the output through forward propagation, compares it with the true results, and uses the backpropagation algorithm to adjust weights and biases to reduce prediction errors. This process is repeated until the network can accurately predict or classify new, unseen data.

[0054] Example 2: Please refer to Figure 2 , Figure 2 This invention provides an architectural schematic diagram of a system for detecting sealing nail defects based on an improved graph attention mechanism, comprising: Network architecture module 10 is used to construct a semantic segmentation network for segmenting defective regions; The data processing module 20 and the electrical connection network architecture module 10 are used to aggregate local features using vector attention operators, generate a correlation coefficient matrix, and constrain the correlation coefficient matrix according to spatial distance relationships to obtain the attention weight matrix of the semantic segmentation network; they are also used to add normal vector feature encoding to the edge convolution operation process to obtain the edge convolution operator of the semantic segmentation network. The model training module 30 and the electrical connection data processing module 20 are used to build a semantic segmentation model based on the semantic segmentation network, and to train the semantic segmentation model using a pre-built training set of sealing nail defects to obtain the network parameters of the semantic segmentation model. The defect detection terminal 40 and the electrical connection model training module 30 are used to detect or identify defects in the sealing nails using a trained semantic segmentation model.

[0055] The construction methods or processes of the semantic segmentation network and semantic segmentation model in the network architecture module 10, data processing module 20 and model training module 30 have been described in detail in Embodiment 1, so they will not be repeated in this embodiment.

[0056] Based on the constructed and trained semantic segmentation model, it can accurately segment defect regions and identify potential defects that traditional algorithms cannot recognize, effectively improving the accuracy of defect detection.

[0057] Based on the same concept, embodiments of the present invention also provide a computer-readable storage medium storing at least one instruction, which is loaded and executed by a processor to implement a method for detecting sealing nail defects based on an improved graph attention mechanism provided in embodiments of the present invention.

[0058] Any combination of one or more computer-readable media may be used. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device.

[0059] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.

[0060] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including—but not limited to—wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0061] Computer program code for performing the operations of this invention can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0062] Based on the same concept, embodiments of the present invention also provide a computer program product, including a computer program / instruction, which, when executed by a processor, implements a method for detecting sealing nail defects based on an improved graph attention mechanism provided in embodiments of the present invention.

[0063] Computer program products may be loaded onto computer devices, and the components of computer devices may include, but are not limited to: one or more processors or processing units, system memory, and buses connecting different system components (including system memory and processing units).

[0064] Computer devices typically include a variety of computer system-readable media. These media can be any available media that can be accessed by a computer device, including volatile and non-volatile media, and removable and non-removable media.

[0065] System memory may include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. The computer device may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system may be used to read and write non-removable, non-volatile magnetic media. The computer program product has a set (e.g., at least one) of program modules configured to perform the functions of the various embodiments of the present invention.

[0066] A program / utility having a set (at least one) of program modules can be stored, for example, in memory. Such program modules include, but are not limited to, an operating system, one or more applications, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. The program modules typically perform the functions and / or methods described in the embodiments of this invention.

[0067] Computer devices can also communicate with one or more external devices (such as keyboards, pointing devices, monitors, etc.), one or more devices that enable users to interact with the computer device, and / or any device that enables the computer device to communicate with one or more other computing devices (such as network interface cards, modems, etc.). This communication can be performed through input / output (I / O) interfaces. Furthermore, computer devices can communicate with one or more networks (such as local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via network adapters. As shown in the figure, the network adapter communicates with other modules of the computer device via a bus. It should be understood that other hardware and / or software modules can be used in conjunction with the computer device, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0068] The processing unit executes various functional applications and data processing by running programs stored in the system memory, such as implementing a method for detecting sealing nail defects based on an improved graph attention mechanism provided in this embodiment of the invention.

[0069] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware, or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0070] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for detecting sealing nail defects based on an improved graph attention mechanism, characterized in that, include: Construct a semantic segmentation network for segmenting defective regions; The vector attention operator is used to aggregate local features to generate a correlation coefficient matrix. The correlation coefficient matrix is ​​then constrained according to spatial distance relationships to obtain the attention weight matrix of the semantic segmentation network. Add normal vector feature encoding to the edge convolution operation process to obtain the edge convolution operator of the semantic segmentation network; A semantic segmentation model is constructed based on the semantic segmentation network, and the semantic segmentation model is trained using a pre-built training set of sealing nail defects to obtain the network parameters of the semantic segmentation model. Detect or identify defects in sealing nails using a trained semantic segmentation model; Before aggregating local features using the vector attention operator to generate a correlation coefficient matrix, and constraining the correlation coefficient matrix according to spatial distance relationships to obtain the attention weight matrix of the semantic segmentation network, the method further includes: Construct a graph structure for the point cloud data of the sealing nail; specifically including: Construct a directed graph To represent the local features of point cloud data; With each Using the center point as the basis, and based on the relative positions of the points, Construct a k-nearest neighbor graph of type X; in, It is a set of vertices. X is the set of edges, k is the k value of the k-nearest neighbor algorithm, and X is the set of point features in the point cloud data. The construction of the semantic segmentation network for segmenting defective regions specifically includes: Based on the 2D image semantic segmentation network U-Net, a semantic segmentation network for segmenting defect regions is constructed. The semantic segmentation network is an encoder-decoder structure, including: a graph attention module, a downsampling module, a graph convolution module, and an upsampling module; The graph attention module is the core feature extraction structure used to encode the input features; the graph convolution module in the decoding layer can add normal vector feature encoding of points to enhance the features extracted by the encoding layer. The process of aggregating local features using the vector attention operator to generate a correlation coefficient matrix is ​​as follows: Based on the k-nearest neighbor graph, the center point and its adjacent neighboring points Characteristic differences ( Using this as input, a correlation coefficient matrix is ​​generated using subtraction; the correlation coefficient matrix is ​​calculated as follows: ,in, and It consists of two independent linear layers; The process of adding normal vector feature encoding to the edge convolution operation to obtain the edge convolution operator of the semantic segmentation network specifically includes: The parameters of the convolution kernel in the graph convolution module are designed, and the edge kernel operator of the graph convolution module is calculated. The calculation formula for the edge kernel operator is as follows: , and These are the parameters of the convolution kernel; Add normal vector feature encoding to the edge core operator; update the calculation formula of the edge core operator to... ; in, Let be a nonlinear function, where and The center point and neighboring points The normal vector.

2. The method for detecting sealing nail defects based on an improved graph attention mechanism according to claim 1, characterized in that, The expression for spatial distance is: , for spatial coordinates, for Spatial coordinates; The attention weight matrix of the semantic segmentation network is calculated as follows: 。 3. The method for detecting sealing nail defects based on an improved graph attention mechanism according to claim 1, characterized in that, The process of constructing a semantic segmentation model based on the semantic segmentation network and training the model using a pre-built training set of sealing nail defects to obtain the network parameters of the semantic segmentation model specifically includes: Adjust the model training parameters according to the defect size in the sealing nail defect training set; The semantic segmentation model was trained using the sealing nail defect training set, and the most suitable network parameters were obtained through multiple training sessions as the network parameters of the semantic segmentation model.

4. The method for detecting sealing nail defects based on an improved graph attention mechanism according to claim 3, characterized in that, The step of adjusting the model training parameters according to the defect size in the sealing nail defect training set includes: For training samples with small defect sizes in the sealing nail defect training set, weights based on the label proportion are added to the loss function; the loss function... Expressed as: , ; Where C is the number of categories. This is the prediction result output by the network, where y is the label and w is the prediction result. c It represents the label weights; N is the total number of points in the dataset, n c It is the total number of points of one class in the dataset.

5. The method for detecting sealing nail defects based on an improved graph attention mechanism according to claim 3, characterized in that, Before constructing the graph structure from the point cloud data of the sealing nail, the following is also included: Multiple sealing nail point cloud data are collected and labeled to construct the datasets required for training and testing; the datasets required for training and testing include a sealing nail defect training set and a sealing nail defect detection test set; Before using the trained semantic segmentation model to detect or identify defects in the sealing nail, the method further includes: The trained semantic segmentation model is tested using a sealing nail defect detection test set. The test results are stored in the form of txt text and visualized using point cloud rendering.

6. The method for detecting sealing nail defects based on an improved graph attention mechanism according to claim 5, characterized in that, The process of collecting and labeling multiple sealing nail point cloud data to construct the dataset required for training and testing specifically includes: Point cloud data of two types of sealing nails, flat nails and concave nails, were collected using a 3D line scan camera; The welding area of ​​the point cloud data of the concave nail was segmented using the RANSAC algorithm to obtain data samples; Data augmentation is performed on the weld area samples to expand the number of data samples and form a dataset; Use annotation tools to label the data samples in the dataset to build the dataset needed for training and testing.

7. A system for detecting sealing nail defects based on an improved graph attention mechanism, comprising: The network architecture module is used to build a semantic segmentation network for segmenting defective regions; The data processing module, electrically connected to the network architecture module, is used to aggregate local features using vector attention operators, generate a correlation coefficient matrix, and constrain the correlation coefficient matrix according to spatial distance relationships to obtain the attention weight matrix of the semantic segmentation network; it is also used to add normal vector feature encoding to the edge convolution operation process to obtain the edge convolution operator of the semantic segmentation network. The model training module is electrically connected to the data processing module and is used to construct a semantic segmentation model based on the semantic segmentation network, and to train the semantic segmentation model using a pre-constructed training set of sealing nail defects to obtain the network parameters of the semantic segmentation model. The defect detection terminal is electrically connected to the model training module and is used to detect or identify defects in the sealing nail using the trained semantic segmentation model. The data processing module is also used to construct a graph structure for the point cloud data of the sealing nail, specifically including: Construct a directed graph To represent the local features of point cloud data; With each Using the center point as the basis, and based on the relative positions of the points, Construct a k-nearest neighbor graph of type X; in, It is a set of vertices. X is the set of edges, k is the k value of the k-nearest neighbor algorithm, and X is the set of point features in the point cloud data. The construction of the semantic segmentation network for segmenting defective regions specifically includes: Based on the 2D image semantic segmentation network U-Net, a semantic segmentation network for segmenting defect regions is constructed. The semantic segmentation network is an encoder-decoder structure, including: a graph attention module, a downsampling module, a graph convolution module, and an upsampling module; The graph attention module is the core feature extraction structure used to encode the input features; the graph convolution module in the decoding layer can add normal vector feature encoding of points to enhance the features extracted by the encoding layer. The process of aggregating local features using the vector attention operator to generate a correlation coefficient matrix is ​​as follows: Based on the k-nearest neighbor graph, the center point and its adjacent neighboring points Characteristic differences ( Using this as input, a correlation coefficient matrix is ​​generated using subtraction; the correlation coefficient matrix is ​​calculated as follows: ,in, and It consists of two independent linear layers; The process of adding normal vector feature encoding to the edge convolution operation to obtain the edge convolution operator of the semantic segmentation network specifically includes: The parameters of the convolution kernel in the graph convolution module are designed, and the edge kernel operator of the graph convolution module is calculated. The calculation formula for the edge kernel operator is as follows: , and These are the parameters of the convolution kernel; Add normal vector feature encoding to the edge core operator; update the calculation formula of the edge core operator to... ; in, Let be a nonlinear function, where and The center point and neighboring points The normal vector.

8. A computer-readable storage medium storing at least one instruction, characterized in that, The instructions are loaded and executed by the processor to implement a method for detecting sealing nail defects based on an improved graph attention mechanism as described in any one of claims 1-6.

9. A computer program product, comprising a computer program / instruction, characterized in that, When the computer program / instruction is executed by the processor, it implements the method for detecting sealing nail defects based on an improved graph attention mechanism as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Sealing nail defect detection method and system

    CN115496728A

  • Sealing pin welding defect detection method, storage medium and electronic device

    CN116630264B

  • Communication equipment twin point cloud completion and defect detection method based on regional reasoning

    CN122200138A

  • Defect Detection, Mesh Cleanup, and Mesh Cleanup Validation in Digital Dentistry

    US20250217663A1