CAD model gap defect detection method and device based on deep learning

By employing parameterized representations and data augmentation strategies from deep learning, combined with recurrent convolutional neural networks and multi-head self-attention mechanisms, the threshold sensitivity and adaptability issues in traditional CAD model gap detection are resolved, achieving high-precision and automated gap defect detection.

CN121032959APending Publication Date: 2025-11-28ZHEJIANG SCI-TECH UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511143328.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-15
Publication Date
2025-11-28

AI Technical Summary

Technical Problem

Existing technologies for detecting gap defects in CAD models suffer from threshold sensitivity issues, poor adaptability to irregular shapes, and insufficient robustness, leading to misjudgments and omissions of critical defects, which affect product performance and detection efficiency.

Method used

By employing a deep learning-based approach, constructing parameterized representation methods and data augmentation strategies, and designing recurrent convolutional neural networks and multi-head self-attention mechanisms, end-to-end gap defect detection is achieved. This avoids the subjectivity of threshold setting in traditional methods and improves detection accuracy and robustness.

Benefits of technology

It significantly improves the accuracy and efficiency of gap defect detection, can accurately depict complex geometric shapes, reduces reliance on engineers' experience, and promotes intelligent inspection of CAD models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121032959A_ABST
    Figure CN121032959A_ABST
Patent Text Reader

Abstract

The invention discloses a CAD (Computer Aided Design) model gap defect detection method and device based on deep learning, which are mainly applied to the field of computer aided design and engineering. The method comprises the following six core steps: firstly, constructing a data set covering various typical gap defects, and expanding the sample size through a data amplification technology; then coding processing is carried out on geometric features of the model, and a deep convolutional neural network is built on the basis; and finally completing model training and gap defect detection. A corresponding device is composed of a data acquisition module, an amplification module, a geometric feature coding module, a detection analysis module and the like, and a matched computer readable storage medium stores program codes for realizing the method. According to the method, the gap defect detection precision is remarkably improved, the adaptability to the complex geometrical morphology is enhanced, and the model generalization ability is effectively improved. Popularization and application of the method can promote intelligent upgrading of a detection process, reduce dependence on experience of engineers, improve detection efficiency and provide technical support for automatic geometric cleaning.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of computer-aided design and computer-aided engineering, and particularly relates to a CAD model gap defect detection method and device based on deep learning, which is used for detecting gap defects in a CAD model. BACKGROUND

[0002] In the field of digital manufacturing, CAD technology has become the core support of product lifecycle management, and the integrity of its topological structure and the standardization of its geometric features directly affect the convergence of CAE analysis and the feasibility of rapid prototyping manufacturing. However, geometric defects (such as gaps, holes, etc.) generated in the design iteration process often lead to more than 60% of engineering time being consumed in the CAE preprocessing stage, making geometric cleaning and repair a key technical bottleneck in bridging design and analysis. The current mainstream geometric correction method mainly relies on interactive operation of engineers and uses semi-automatic tools for feature recognition and boundary repair. This traditional mode faces double challenges: first, the mutual coupling of multi-scale features in complex assemblies significantly increases the complexity of manual intervention; second, the built-in repair algorithm of commercial software generally has the following problems when dealing with non-manifold edges and small gaps due to its reliance on preset threshold tolerance for judgment:

[0003] Threshold sensitivity problem: the traditional rule-based method requires manual setting of geometric deviation threshold (such as gap width tolerance), but this threshold is difficult to define uniformly when facing complex models with multiple scale features: a too small threshold will lead to a large number of false defects being misjudged, increasing the repair workload; a too large threshold will miss critical defects, affecting product performance.

[0004] Poor adaptability to irregular shapes: when the gap presents a non-standard geometric shape (such as jagged, curved transition gap) or geometric nesting with adjacent features, the matching algorithm based on fixed rules has difficulty in accurately extracting the defect boundary, which can easily lead to topological misjudgment.

[0005] Lack of robustness: when dealing with models with complex free-form surfaces or non-manifold topologies, traditional methods often have problems of over-repair or incomplete repair due to the lack of understanding of the geometric context.

[0006] In this context, the research of intelligent geometric repair technology has become a key breakthrough direction in the field of intelligent manufacturing. In view of the limitations of existing defect recognition algorithms, this paper proposes a data-driven CAD model gap defect detection framework, the main innovations include:

[0007] New geometric representation method: a parameterized representation method for closed chains is constructed, which converts irregular geometric defects into a vector sequence with rotational invariance as the input of the deep learning model.

[0008] Data augmentation learning strategy: RBF transformation is used to augment data. By introducing controllable perturbations to simulate geometric deviations in the manufacturing process, the robustness of the model to noisy data is improved.

[0009] Deep feature extraction architecture: A feature encoder based on a recurrent convolutional neural network was designed, combined with a multi-head self-attention mechanism, which enables the model to capture long-distance dependencies between feature points in closed-chain representations and achieve understanding of complex geometric contexts.

[0010] End-to-end detection framework: By training directly from discrete sampling points of the CAD model, defect features are learned, avoiding the subjectivity of threshold setting in traditional methods and significantly improving the recognition accuracy of multi-scale gap defects.

[0011] This framework overcomes the limitations of traditional rule recognition methods through a data-driven learning paradigm. Experimental results show that in the testing of industrial-grade CAD models containing various complex geometric defects, the detection accuracy of this method has a significant advantage over traditional methods, providing an effective solution for the automated quality inspection of CAD models. Summary of the Invention

[0012] This invention proposes a method and apparatus for detecting gap defects in CAD models based on deep learning. By extracting the geometric information of the gap (including coordinate points and tangent vectors) to construct a feature representation, this representation can accurately characterize the local morphology and variation trend of the curve. Combined with the powerful nonlinear fitting capability of deep neural networks, the model can automatically learn the deep mapping relationship between gap features and geometric information. The trained model can be efficiently used for accurate prediction of gap defects on a test set, significantly improving detection accuracy compared to traditional methods.

[0013] To achieve the above-mentioned technical objectives and effects, the present invention provides the following technical solution:

[0014] A deep learning-based method for detecting gap defects in CAD models includes the following steps:

[0015] Step 1. Construct a dataset for detecting gap defects: Extract closed free edges from several B-Rep CAD models to form a set of closed chains, and manually label each closed boundary edge as a gap or non-gap to form a basic training dataset.

[0016] Step 2. Augment the basic training dataset: Use the radial basis function deformation method that preserves the spacing to deform each closed chain in order to increase the amount of training data;

[0017] Step 3. Encode the geometric features of the closed chain: Sample a fixed number of points on the closed chain, calculate the three-dimensional coordinates and unit tangent vector of each sample point, and concatenate the coordinates and tangent vectors of all sample points as the feature vector of the boundary edge set;

[0018] Step 4. Construct a deep convolutional neural network for gap defect detection: Design a neural network architecture that includes a recurrent convolution feature extraction module, a multi-head self-attention enhancement module, and a classification decision module. The recurrent convolution module uses boundary recurrent operations to handle the head-to-tail connection characteristics of closed chains, the multi-head self-attention module enhances feature expression through weighted fusion, and the classification decision module outputs the probability that a closed chain is a gap through a multilayer perceptron.

[0019] Step 5. Train the deep neural network model parameters: Use the geometric features of closed chains in the training dataset as input, the labels as supervised output, and the binary cross-entropy loss function and gradient descent optimization strategy to train the model;

[0020] Step 6. Use the trained neural network to detect gap defects: Extract closed chains from the CAD model, input their geometric features into the neural network, and determine whether it is a gap defect based on the output probability.

[0021] Furthermore, the data amplification in step 2 includes:

[0022] Sample the same number of points for each closed chain. A globally uniform distribution of sampling points is achieved through an iterative optimization algorithm;

[0023] The specific process is as follows: initial sampling points are allocated according to the curve length ratio, the area with the largest sampling point spacing is identified and locally densified, and the oversampled area is sparsified. After multiple rounds of dynamic adjustment, a uniform distribution is achieved.

[0024] Furthermore, the radial basis function deformation method in step 2 specifically includes:

[0025] The deformation function is defined as f:R 3 →R 3 :

[0026]

[0027] in, Let D be the radial basis function, D be the normalization factor of the basis function, N be the number of collocation points, and c be the radial basis function. i Assign point coordinates to the preset radial basis functions, where ω is a 3×N coefficient matrix, A is a 3×3 affine transformation, and t is a translation vector;

[0028] Configuration points are set near the skeleton of a closed-loop polygon: points with an included angle greater than 120° and less than 180° are considered ordinary points, while those with an included angle greater than 0° and less than 120° are considered inflection points. For ordinary points, the search approximate nearest vertex x is performed. j :

[0029]

[0030] Where, τ i With τ j Let i and j be the normalized tangent vectors at vertices i and j respectively. Then the position of the placement point is set as the midpoint between a normal vertex and its opposite vertex.

[0031] Furthermore, in step 2, a closed-loop characteristic transformation is driven by energy-driven deformation while preserving rigidity as much as possible.

[0032] Construct an adjacency graph: Define 10 neighboring vertices for ordinary vertices, including: left and right ring neighboring vertices, opposite vertices, opposite vertex neighboring vertices, and binormal vertices; define 5 neighboring vertices for inflection points.

[0033] The deformation energy function is:

[0034] E(ω,A,t)=E arap (ω,A,t)+w1E pos (ω,A,t)+w2E reg (ω,A,t)

[0035] in, Where R i This is the rotation transformation matrix; Where g i The location of the target point; The regularization term; the target point position g i Calculated as: g i =c ave +M×(c i -c ave ), where c ave Let M be the center of the configuration point, and M be a randomly generated affine transformation matrix;

[0036] The solution employs a local-global iteration: local phase updates {R} I The global phase is updated to ω,A,t.

[0037] Furthermore, in step 3, the geometric feature encoding is as follows: the three-dimensional coordinates and unit tangent vector of each sampling point constitute a six-dimensional vector, and all point vectors are concatenated to form an N×6 feature matrix, wherein the number of sampling points N is fixed at 128.

[0038] Furthermore, the recurrent convolution feature extraction module in step 4 includes three levels of convolutional blocks:

[0039] Each convolutional block contains, in sequence:

[0040] The first-level convolutional layer is configured with 16 filters of size 3×1 and a stride of 1;

[0041] The second-level convolutional layer is configured with 32 filters of size 3×1 and a stride of 1;

[0042] The third convolutional layer is configured with 64 filters of size 3×1 and a stride of 1;

[0043] Each convolutional layer is followed by a batch normalization layer, a max pooling layer, and a ReLU activation function, where the pooling layer uses one-dimensional max pooling with a size of 3 and a stride of 2.

[0044] Looping convolution operation: When the convolution window covers the first sampling point, the last sampling point is taken as the previous neighbor; when it covers the last sampling point, the first sampling point is taken as the next neighbor.

[0045] Furthermore, the multi-head self-attention enhancement module in step 4 specifically comprises:

[0046] Input the 64×15D features extracted from the convolutional block, and calculate the attention score using a multi-head self-attention mechanism:

[0047] MultiHead(f)=Concat(h1,...,h m W o

[0048]

[0049] Q i K i V i Generated by feature linear transformation, with the number of attention heads set to 8;

[0050] Output feature enhancement is as follows:

[0051] l′=l+MultiHead(l)l,

[0052] Furthermore, the training process in step 5 includes:

[0053] The gradient is calculated using the backpropagation algorithm and then the parameters are updated using the AdamW optimizer.

[0054] The loss function is binary cross-entropy:

[0055]

[0056] Where m is the number of closed chains, t i For binary true labels, p iTo predict probabilities, a Dropout rate of 0.1 is introduced to suppress overfitting.

[0057] On the other hand, the present invention also provides a deep learning-based CAD model gap defect detection device, comprising:

[0058] Data acquisition module: used to extract closed free edges from CAD models and label them;

[0059] Data augmentation module: Executes the RBF transformation method to generate augmented datasets;

[0060] Feature encoding module: Calculates the coordinates and tangent vectors of the closed-chain sampling points to form geometric features;

[0061] Neural network module: integrates recurrent convolution, multi-head self-attention and multilayer perceptron, outputting defect probability;

[0062] Detection execution module: Loads the trained model and performs defect prediction;

[0063] The device structure includes a processor and a memory. The memory stores executable instructions, and the processor executes the instructions to implement the above-mentioned deep learning-based CAD model gap defect detection method.

[0064] On the other hand, the present invention also provides a computer-readable storage medium having a computer program stored thereon, characterized in that, when the program is executed by a processor, it implements the above-mentioned deep learning-based CAD model gap defect detection method or apparatus.

[0065] Compared with the prior art, the beneficial effects of the present invention are:

[0066] Significantly improves detection accuracy and provides a reliable basis for subsequent repair: By constructing a discrete representation method with sampling point coordinates and tangent vectors as the core, the geometric details and morphological features of the curve are accurately preserved; combined with the circular convolution operation designed for closed chains, the information loss at the boundary of traditional convolution is effectively avoided, enabling the model to capture the global structural features of the closed curve more completely, greatly improving the accuracy of gap defect detection, and providing accurate defect location and boundary information for subsequent automated repair.

[0067] Enhanced adaptability to complex geometric shapes: Compared with traditional detection methods based on fixed thresholds, this invention uses a combination of coordinates and tangent vectors to represent curve shape changes, which is more sensitive to changes in curve shape. It can accurately characterize the geometric features of irregular gaps such as sawtooth shapes and curved transitions, effectively solving the problem of misjudging non-standard morphological defects by traditional methods.

[0068] Enhancing Model Generalization Through Deep Feature Learning: An architecture integrating convolutional neural networks and multi-head self-attention mechanisms extracts key local features through convolutional blocks while capturing deep correlations and global dependencies between features using multi-head self-attention, thus improving the ability to identify multi-scale gaps in complex scenarios. This data-driven learning approach eliminates the need for manually defined rules, significantly improving the model's generalization performance across different CAD models and gap types.

[0069] Promoting the intelligent upgrade of CAD model defect detection: This invention breaks through the reliance on manual interaction in traditional geometric repair. Through an end-to-end deep learning framework, it realizes the automatic identification and classification of gap defects, which not only reduces the reliance on engineers' experience, but also improves detection efficiency, providing key technical support for intelligent geometric cleaning in digital manufacturing processes. Attached Figure Description

[0070] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the description of the specific embodiments will be briefly introduced below. Obviously, the accompanying 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.

[0071] Figure 1 This is a flowchart of a deep learning-based CAD model gap defect detection method according to an embodiment of the present invention;

[0072] Figure 2 This is a schematic diagram representing the gap in this invention.

[0073] Figure 3 This is a schematic diagram illustrating the selection of the placement and perturbation points for the RBF transform in this invention.

[0074] Figure 4 This is a schematic diagram of the RBF transformation results under different perturbations in this invention;

[0075] Figure 5 This is a schematic diagram showing the RBF transformation results of gaps and holes in this invention;

[0076] Figure 6 This is a schematic diagram of the deep neural network architecture used in this invention;

[0077] Figure 7 This is a schematic diagram of the device in the present invention. Detailed Implementation

[0078] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0079] Example 1

[0080] This embodiment relates to a method and apparatus for detecting gap defects in CAD models based on deep learning. It utilizes a deep neural network, a learning model with strong fitting capabilities, to learn the deep-level relationship between the geometric information of gaps and curves, thereby more accurately detecting gaps in CAD models.

[0081] Figure 1 This is a flowchart of the deep learning-based CAD model gap defect detection method in this embodiment. The gap defect method includes the following steps: Step 101, acquiring information on gaps and holes in the CAD model; Step 102, extracting the geometric features of gaps and holes; Step 103, using RBF transformation to amplify the data; Step 104, constructing recurrent data and building a deep neural network to capture the deep-level relationship between the geometric features of gaps and curves; Step 105, training the model using the training set and predicting data in the test set.

[0082] Specifically, in one embodiment, the deep learning-based CAD model gap defect detection method includes the following steps:

[0083] Step 1: Construct a dataset for detecting gaps and defects, serving as the basic training dataset. In the given CAD model, a gap is represented by a set of connected free edges. A free edge is a curve with only one surface adjacent to it, containing the IDs of multiple curves. These IDs allow you to locate the corresponding curve in the CAD model. Each set of boundary edges has a corresponding label during reading; gaps and holes are labeled 1 and 0, respectively. The constructed training dataset contains 260 samples, including 157 positive samples (labeled 1) and 103 negative samples (labeled 0).

[0084] Step 2: Augment the basic training dataset for deep learning training: Use the spacing-preserving radial basis function (RBF) deformation method to deform each closed chain, thereby increasing the amount of training data.

[0085] First, sample the same number of points for each closed chain in the dataset. The specific process is as follows: First, for each curve in the closed chain, a corresponding number of sampling points are allocated according to the proportion of the curve length to the total length. After this initial sampling density allocation, the actual total number of sampling points in the closed chain may deviate from the preset total. To address this, an iterative optimization algorithm is introduced: based on the initial allocation result, localized dense sampling is performed by identifying the region with the largest spacing between sampling points, while oversampling regions with excessively dense sampling points are sparsified. After multiple rounds of dynamic adjustment, the sampling points of the closed chain are finally made to achieve a globally uniform distribution.

[0086] Then, the closed chain is transformed using a radial basis function deformation method to generate more training data. Specifically, the deformation function is expressed as a smooth radial basis function in the following form, i.e., f:R 3 →R 3 :

[0087]

[0088] in Let D be the radial basis functions, D be the normalization factor of the basis functions, and D be the number of collocation points. i The coordinates of the points are assigned to the preset radial basis functions, where ω is a 3×N coefficient matrix, A is a 3×3 affine transformation, and t is the translation vector. This invention sets the points near the skeleton of the polygon formed by the closed chain. Specifically, based on a simple angle threshold rule, the vertices constituting the closed chain polygon are divided into two categories: ordinary points and inflection points. If the angle (0–180°) is greater than 120°, it is classified as the former; otherwise, it is classified as the latter. For all vertices, the nearest neighbor is searched as the pair of vertices.

[0089]

[0090] Where τ i With τ j If the normalized tangent vectors at vertices i and j are respectively, then the position of the placement point is set as the midpoint between a normal vertex and its opposite vertex.

[0091] Next, a feature-preserving transformation of the closed chain is driven using deformation energy that preserves the spacing as much as possible. Specifically, the polygons represented by the closed chain are constructed into an adjacency graph. For the current vertex, if it is a normal vertex, 10 adjacent vertices are constructed as its neighborhood, selected as follows: the first 4 are its left and right two-ring neighborhood vertices, used to describe the local geometry; the 5th is its opposite vertex; the 6th to 9th are the left and right two-ring neighborhood vertices of the opposite vertex, used to describe the spacing information of the gap; the 10th is located on the binormal direction of this vertex, and its length is taken as the average side length L of the gap polygon. avg To prevent the three-dimensional transformation matrix from degenerating when the data is approximately planar, if it is an inflection point, then construct 5 neighboring vertices, corresponding to the first 4 and the 10th vertices of the ordinary vertices respectively.

[0092] Subsequently, a deformation model of the adjacency graph is performed using a similar approach based on the deformation energy of the most rigid possible (ARAP) mesh, namely:

[0093] E(ω, A, t) = E arap (ω, A, t) + w1E pos (ω, A, t) + w2E reg (ω, A, t).

[0094] in, Primarily used to maintain the geometry and spacing of gaps, where R i This is the rotation transformation matrix; Used to constrain the target location of the configuration point, where g i The location of the target point; `w1` and `w2` are regularization terms used to improve the robustness of the algorithm during numerical solutions; `w1` and `w2` are positive weights, defaulting to 1000 and 0.1 respectively. The solution process employs alternating local and global iterations: that is, the rotation matrix set `{R}` is updated locally. i In the global phase, solve the system of linear equations, update variables ω, A, t, until convergence.

[0095] Regarding formula E pos g i For configuration point c i The target location is calculated using the following formula:

[0096] g i =c ave +M×(c i -c ave ),

[0097] Among them, c ave Let M be the center coordinates of all configuration points. M is a 3×3 positive definite affine transformation. The diagonal elements are set to a fixed value of 1, and the other elements can be randomly generated and their range is restricted to [-σ,σ].

[0098] Finally, using the randomly generated target locations, the minimum value of the ARAP deformation energy function is solved to obtain the new coordinates of the closed-chain sampling points. Simultaneously, to update the tangent of the closed polygon (for subsequent feature encoding), approximate calculations are performed using the deformation coordinates of points near the original tangent:

[0099] τ′ i =normalize(f(x) i +ητ i )-f(x i )),

[0100] Where η is taken as: 0.02L avg`normalize` is the normalization function. The training dataset was ultimately expanded to 2860 samples.

[0101] Step 3: Encode the geometric features of the closed chain. A fixed number of points are sampled on each closed chain. The coordinates and tangent vectors of the sampled points are calculated, and the coordinates and tangent vectors of all sampled points are concatenated to form the features of the boundary edge set. Different CAD models have different numbers of free edges. N points are sampled for each closed chain, and each point contains 3D coordinates and a tangent vector, resulting in a geometric feature of size N×6D. The extracted features will then be used as the input to the subsequent neural network. Specific parameters are: 128 samples, resulting in a data size of 768D.

[0102] Step 4: Constructing a deep convolutional neural network for gap defect detection: Considering the characteristics of closed-chain structures, a deep neural network architecture integrating recurrent convolution and multi-head self-attention mechanisms was designed. This architecture takes the geometric features of the closed chain (coordinate points and tangent vectors) as input and collaboratively performs probabilistic prediction of gap defects through the following modules:

[0103] The recurrent convolutional feature extraction module employs a three-level cascaded convolutional block structure. Each convolutional block contains a convolutional layer, a batch normalization layer, a max-pooling layer, and a ReLU activation function. The encoder contains three convolutional blocks, a multi-head self-attention module, and a global pooling layer. A flattening layer serves as a transition from the encoder to the output layer. The output layer decodes the features using a multilayer perceptron and outputs the probability of each closed chain being a gap. Each convolutional block includes a convolutional layer, a normalization layer, a max-pooling layer, and an activation layer. The f, d, and s parameters of the three convolutional layers are set to (16, 3, 1), (32, 3, 1), and (64, 3, 1), respectively. Each convolutional layer is followed by a normalization layer, which stabilizes the network input while reducing the impact of internal covariant shifts and allows for a higher learning rate to accelerate training. Following the normalization layer is a one-dimensional max-pooling layer, which replaces the block with the maximum value. The pooling layer downsamples the feature map along the spatial dimension. The parameters of the pooling layer are the block shape q and the spatial stride s, which are set to 3 and 2, respectively. After the pooling layer, an activation layer is introduced to increase the model's expressive power, improve its learning ability and generalization performance, and the activation function chosen is ReLU.

[0104] Specifically, considering the characteristic of closed chains being connected end-to-end, a recurrent convolution operation was designed: when the convolution window covers the first sampling point, the last sampling point is automatically used as its previous neighbor in the convolution calculation; when the convolution window covers the last sampling point, the first sampling point is automatically used as its next neighbor in the convolution calculation. This boundary handling mechanism ensures the feature consistency of the closed chain globally, effectively avoiding the information loss problem at the endpoints of open curves in traditional convolution.

[0105] Multi-head self-attention enhancement module: This module inputs the feature maps extracted from convolutional blocks into the multi-head self-attention mechanism. It generates attention weights by calculating the correlation matrix between features, and then performs weighted fusion with the original features. This mechanism adaptively focuses on key geometric features (such as curvature abrupt changes and discontinuous regions) within the closed chain, significantly improving feature representation. The multi-head self-attention module primarily enhances the expressive power of the output features of convolutional blocks. It takes the 64×15D features extracted from the convolutional blocks as input and interacts with the multi-head self-attention mechanism to generate attention scores. In this process, the query matrix Q, key matrix K, and value matrix V are all linearly transformed from the feature f. The specific calculation formula for each attention head hi is as follows:

[0106] MultiHead(f)=Concat(h1,...,h m W o

[0107]

[0108] Where d is a scaling factor used to stabilize gradient propagation. The attention heads are set to 8, so the dimension of each head is 1 / 8 of the total feature dimension, generating h. i They are pieced together and integrated into the final attention score through a linear transformation.

[0109] To more fully integrate the information gain from the original features and the attention mechanism, the attention score is weighted and summed with the module's input, and then added to the input before weighting to obtain the enhanced output features, specifically:

[0110] l′=l+MultiHead(l)l,

[0111] Here, f' represents the output feature enhanced by the attention score. In this way, the model can more effectively focus on important regional features in the input data, thereby improving overall performance. The higher the attention score, the more worthy the model is of attention to that region.

[0112] The classification decision module decodes the enhanced features using a multilayer perceptron (MLP), employing the Mish non-linear activation function. The final output is the probability of whether a closed chain is a gap. Network training uses a cross-entropy loss function and the Adam optimizer, automatically optimizing model parameters through end-to-end learning.

[0113] This architecture processes the topological properties of closed chains through recurrent convolution and captures long-distance dependencies between geometric features using a self-attention mechanism, forming a complete link from local feature extraction to global semantic understanding.

[0114] Step 5: Train the parameters of the deep neural network model: Use the geometric features of the closed chains in the training dataset as the input of the neural network, use their labels as the supervised output, train the deep learning model, and complete the calculation of the neural network parameters.

[0115] The loss function used is the binary cross-entropy loss between the predicted probability and the true label value. The formula for calculating the total loss score is as follows:

[0116]

[0117] Where m is the number of closed chains, t i For binary true labels, p i To predict probabilities.

[0118] During the neural network model training phase, to ensure the reproducibility and stability of the experimental results, a fixed random seed of 42 was used in all experiments, and the model was trained for 100 epochs. The backpropagation algorithm was used for gradient calculation, combined with a gradient descent optimization strategy to iteratively update the network parameters. Specifically:

[0119] Error backpropagation mechanism: The loss function between the model's predicted value and the true label is calculated through forward propagation. Then, the error gradient is backpropagated from the output layer to each hidden layer using the chain rule, thereby determining the contribution of each network parameter to the total loss.

[0120] Gradient descent optimization strategy: The AdamW optimizer is used to iteratively update network parameters based on parameter gradients calculated by backpropagation. Adaptive learning rate and momentum term accelerate convergence and avoid local optima. At the same time, 0.1 Drop Path regularization is introduced to suppress overfitting and improve the model's generalization ability.

[0121] Step 6: Use the trained neural network to detect gap defects: Extract closed chains from the CAD model and use their geometric features as input to the deep neural network. Determine whether it is a gap defect based on the output probability.

[0122] This invention requires some manual operation. First, a text file containing the gaps and holes corresponding to the model is needed. Then, a script reads the model and its corresponding text file, calculates the 3D coordinates and tangent vectors of its sampling points, and writes the boundary edge set and corresponding data into another text file. Simultaneously, the RBF transform is called to transform this data, and the new data is also written to a text file. Next, the system calls a neural network system written in Python. In the neural network system, the text files of the training and test sets are read. The system then uses the data in the training set to perform multiple training iterations, and finally predicts the data in the test set.

[0123] This invention also provides a deep learning-based CAD model gap defect detection device, comprising:

[0124] Data acquisition module: used to extract closed free edges from CAD models and label them;

[0125] Data augmentation module: Executes the RBF transformation method to generate augmented datasets;

[0126] Feature encoding module: Calculates the coordinates and tangent vectors of the closed-chain sampling points to form geometric features;

[0127] Neural network module: integrates recurrent convolution, multi-head self-attention and multilayer perceptron, outputting defect probability;

[0128] Detection execution module: Loads the trained model and performs defect prediction;

[0129] The device structure includes a processor and a memory. The memory stores executable instructions, and the processor executes the instructions to implement the above-mentioned deep learning-based CAD model gap defect detection method.

[0130] This invention also provides a computer-readable storage medium storing a program thereon, which, when executed by a processor, implements a deep learning-based CAD model gap defect detection method as described in the above embodiments.

[0131] The computer-readable storage medium can be an internal storage unit of any data processing device as described in any of the foregoing embodiments, such as a hard disk or memory. The computer-readable storage medium can also be an external storage device of any data processing device, such as a plug-in hard disk, smart media card (SMC), SD card, flash card, etc., equipped on the device. Furthermore, the computer-readable storage medium can include both internal storage units and external storage devices of any data processing device. The computer-readable storage medium is used to store the computer program and other programs and data required by the data processing device, and can also be used to temporarily store data that has been output or will be output.

[0132] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements the aforementioned method and apparatus for detecting gap defects in CAD models based on deep learning.

[0133] In the description of this specification, references to terms such as "an embodiment," "example," "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0134] The preferred embodiments of the present invention disclosed above are merely illustrative of the invention. These preferred embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this specification. This specification selects and specifically describes these embodiments to better explain the principles and practical applications of the invention, thereby enabling those skilled in the art to better understand and utilize the invention. The invention is limited only by the claims and their full scope and equivalents.

Claims

1. A method for detecting gap defects in CAD models based on deep learning, characterized in that, Includes the following steps: Step 1. Construct a dataset for detecting gap defects: Extract closed free edges from several B-Rep CAD models to form a set of closed chains, and manually label each closed boundary edge as a gap or non-gap to form a basic training dataset. Step 2. Augment the basic training dataset: Use the radial basis function deformation method that preserves the spacing to deform each closed chain in order to increase the amount of training data; Step 3. Encode the geometric features of the closed chain: Sample a fixed number of points on the closed chain, calculate the three-dimensional coordinates and unit tangent vector of each sample point, and concatenate the coordinates and tangent vectors of all sample points as the feature vector of the boundary edge set; Step 4. Construct a deep convolutional neural network for gap defect detection: Design a neural network architecture that includes a recurrent convolution feature extraction module, a multi-head self-attention enhancement module, and a classification decision module. The recurrent convolution module uses boundary recurrent operations to handle the head-to-tail connection characteristics of closed chains, the multi-head self-attention module enhances feature expression through weighted fusion, and the classification decision module outputs the probability that a closed chain is a gap through a multilayer perceptron. Step 5. Train the deep neural network model parameters: Use the geometric features of closed chains in the training dataset as input, the labels as supervised output, and the binary cross-entropy loss function and gradient descent optimization strategy to train the model; Step 6. Use the trained neural network to detect gap defects: Extract closed chains from the CAD model, input their geometric features into the neural network, and determine whether it is a gap defect based on the output probability.

2. The method for detecting gaps and defects in CAD models according to claim 1, characterized in that, The data amplification in step 2 includes: Sample the same number of points for each closed chain. A globally uniform distribution of sampling points is achieved through an iterative optimization algorithm; The specific process is as follows: initial sampling points are allocated according to the curve length ratio, the area with the largest sampling point spacing is identified and locally densified, and the oversampled area is sparsified. After multiple rounds of dynamic adjustment, a uniform distribution is achieved.

3. The method for detecting gaps and defects in CAD models according to claim 1, characterized in that, The radial basis function deformation method in step 2 specifically includes: The deformation function is defined as f:R 3 →R 3 : in, Let D be the radial basis function, D be the normalization factor of the basis function, N be the number of collocation points, and c be the radial basis function. i Assign point coordinates to the preset radial basis functions, where ω is a 3×N coefficient matrix, A is a 3×3 affine transformation, and t is a translation vector; Configuration points are set near the skeleton of a closed-loop polygon: points with an included angle greater than 120° and less than 180° are considered ordinary points, while those with an included angle greater than 0° and less than 120° are considered inflection points. For ordinary points, the search approximate nearest vertex x is performed. j : Where, τ i With τ j Let i and j be the normalized tangent vectors at vertices i and j respectively. Then the position of the placement point is set as the midpoint between a normal vertex and its opposite vertex.

4. The method for detecting gaps and defects in CAD models according to claim 1, characterized in that, In step 2, the closed-chain characteristic transformation is driven by energy-saving deformation while maintaining rigidity as much as possible. Build Adjacency graph: Define 10 neighboring vertices for ordinary vertices, including: left and right ring neighboring vertices, opposite vertices, opposite vertex neighboring vertices and binormal vertices; define 5 neighboring vertices for inflection points. The deformation energy function is: E(ω,A,t)=E arap (ω,A,t)+w1E pos (ω,A,t)+w2E reg (ω,A,t) in, Where R i Here is the rotation transformation matrix; Where g i The location of the target point; For regularization terms; target point position g i Calculated as: g i =c ave +M×(c i -c ave ), where c ave Let M be the center of the configuration point, and M be a randomly generated affine transformation matrix; The solution employs a local-global iteration: local phase updates {R} I The global phase is updated to ω,A,t.

5. The method for detecting gaps and defects in CAD models according to claim 1, characterized in that, In step 3, the geometric feature encoding is as follows: the three-dimensional coordinates and unit tangent vector of each sampling point constitute a six-dimensional vector, and all point vectors are concatenated to form an N×6 feature matrix, wherein the number of sampling points N is fixed at 128.

6. The method for detecting gap defects in CAD models according to claim 1, characterized in that, The recurrent convolution feature extraction module in step 4 includes three levels of convolutional blocks: Each convolutional block contains, in sequence: The first-level convolutional layer is configured with 16 filters of size 3×1 and a stride of 1; The second-level convolutional layer is configured with 32 filters of size 3×1 and a stride of 1; The third convolutional layer is configured with 64 filters of size 3×1 and a stride of 1; Each convolutional layer is followed by a batch normalization layer, a max pooling layer, and a ReLU activation function, where the pooling layer uses one-dimensional max pooling with a size of 3 and a stride of 2. Looping convolution operation: When the convolution window covers the first sampling point, the last sampling point is taken as the previous neighbor; when it covers the last sampling point, the first sampling point is taken as the next neighbor.

7. The method for detecting gap defects in CAD models according to claim 1, characterized in that, The multi-head self-attention enhancement module in step 4 specifically refers to: Input the 64×15D features extracted from the convolutional block, and calculate the attention score using a multi-head self-attention mechanism: MultiHead(f)=Concat(h1,...,h m )W o Q i K i V i Generated by feature linear transformation, with the number of attention heads set to 8; Output feature enhancement is as follows: l′=l+MultiHead(l)l.

8. The method for detecting gaps and defects in CAD models according to claim 1, characterized in that, The training process in step 5 includes: The gradient is calculated using the backpropagation algorithm and then the parameters are updated using the AdamW optimizer. The loss function is binary cross-entropy: Where m is the number of closed chains, t i For binary true labels, p i To predict probabilities, a Dropout rate of 0.1 is introduced to suppress overfitting.

9. A CAD model gap defect detection device based on deep learning, characterized in that, include: Data acquisition module: used to extract closed free edges from CAD models and label them; Data augmentation module: Executes the RBF transformation method to generate augmented datasets; Feature encoding module: Calculates the coordinates and tangent vectors of the closed-chain sampling points to form geometric features; Neural network module: integrates recurrent convolution, multi-head self-attention and multilayer perceptron, outputting defect probability; Detection execution module: Loads the trained model and performs defect prediction; The device structure includes a processor and a memory, the memory storing executable instructions, and the processor executing the instructions to implement any one of the methods of claims 1-8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the deep learning-based CAD model gap defect detection method or apparatus as described in any one of claims 1-9.

Citation Information

Cited By

  • Geometric defect identification and processing method based on AI large model

    CN122065447A