3D printing defect recognition method and system based on OCT and deep learning
By combining OCT and deep learning methods, a U-net network based on the CBAM attention mechanism was constructed to detect and repair defects in 3D printing in real time, solving the problem of defect detection in complex models and improving printing quality and efficiency.
Patent Information
- Application Number
- CN202410394595.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-02
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2044-04-02
AI Technical Summary
Existing technologies have difficulty in effectively detecting defects such as under-extrusion, over-extrusion, broken wires, and wiredrawing in complex models in extrusion-based 3D printing, and lack the integration of deep learning algorithms, resulting in insufficient detection applicability and automation.
Combining OCT technology and deep learning, a U-net network with the CBAM attention mechanism is constructed. By acquiring OCT data and Gcode information, a defect representation map is generated, and defect repair is performed by real-time detection and dynamic adjustment of printing parameters.
It achieves accurate detection and dynamic repair of tiny defects in the 3D printing process, improves the consistency and efficiency of printing quality, reduces material waste, and is suitable for complex and high-precision industrial manufacturing.
Smart Images

Figure CN118134897B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of 3D printing detection, and in particular to a 3D printing defect recognition method and system based on OCT and deep learning. Background Art
[0002] Optical coherence tomography (OCT), a high-resolution, non-invasive imaging technology, can not only detect the molding effect of the current printing layer during the 3D printing process, but also detect structural information beneath the printed surface layer. Therefore, it is often used for online monitoring and feedback control of the 3D printing process in extrusion-based 3D printing to ensure the accuracy and fidelity of the printed object. Conventional technology uses OCT probes to detect defects in 3D printing filaments, obtaining the diameter distribution and diameter deviation of the printed filament, or obtaining surface depth information of the printed layer. Based on the detection data, it determines whether the current printing layer has broken filament areas, and if so, prints repairs. However, this method only detects normal or broken filament conditions during extrusion printing, and does not demonstrate effective detection of under-extrusion, over-extrusion, or wiredrawing defects. Furthermore, its applicability and effectiveness in identifying and correcting defects in more complex models remain uncertain, and it lacks integration with deep learning algorithms to automate the defect detection process. Summary of the Invention
[0003] The purpose of the present invention is to provide a 3D printing defect recognition method and system based on OCT and deep learning, aiming to solve the problem of real-time defect detection for complex and irregular models in extrusion 3D printing.
[0004] In a first aspect, the present invention provides a 3D printing defect recognition method based on OCT and deep learning, comprising the following steps:
[0005] Step (1), constructing a deep neural network, and training, testing and verifying it;
[0006] 1-1 Obtain a 2D target model image based on Gcode information and a reconstructed OCT print model image of the same print layer, mark them with defect labels, and then divide them into a training set, a test set, and a validation set; the defect labels use a defect representation map defined by at least one defect state;
[0007] 1-2 Build a deep neural network and train, test and validate it;
[0008] The deep neural network adopts the U-net network that introduces the CBAM attention mechanism;
[0009] Step (2): obtaining a 2D target model image based on Gcode information and a reconstructed OCT printing model image of the current printing layer according to the OCT data collected by the OCT system; inputting the 2D target model image and the reconstructed OCT printing model image of the above printing layer into the deep neural network after training, testing and verification to obtain a defect representation map of the above printing layer;
[0010] Step (3): adjusting the printing parameters of the OCT system according to the defect representation diagram to repair the defect.
[0011] In one embodiment, the U-net network that introduces the CBAM attention mechanism is to change the single-channel input of the U-net basic framework to a dual-channel input, and insert the CBAM attention mechanism and the Dropout method in sequence after the DoubleConv layer from the second to the second-to-last layer in the encoding layer;
[0012] The dual-channel input refers to performing channel stacking processing on the 2D target model image and the reconstructed OCT printing model image.
[0013] In one embodiment, the acquisition of the 2D target model image specifically includes:
[0014] 1) Create a 2D target model space on the XY plane based on the field of view of the OCT system;
[0015] 2) Extract the XY coordinate sequence under the same Z coordinate from GCode;
[0016] 3) Generate a 2D printing path using the XY coordinate sequence based on the resolution of the OCT system data;
[0017] 4) Generate a 2D standard model diagram containing target printing parameters based on the printing information in the GCode and the 2D path.
[0018] In one embodiment, obtaining the reconstructed OCT printing model image specifically includes:
[0019] 1) Before printing, measure the printing platform height and calibrate the printing coordinates of the OCT system;
[0020] 2) Use the OCT system to collect OCT data of the printing platform and record the acquisition coordinates;
[0021] 3) After each layer is printed, the OCT system is used to collect OCT data of the printed stent in the current layer;
[0022] 4) Processing the OCT data collected in step 3) extracts the surface points of each OCT data, and then reconstructs the printing model according to the thickness distribution calculation formula.
[0023] The thickness distribution calculation formula is:
[0024] Thickness Print(i) =(Z Imaging_Base +Z Set_Height(i) -Z Imaging_Print(i) )×ΔZ
[0025] Thickness Print(i) represents the thickness distribution of the i-th layer; Z Imaging_Base is the surface point matrix of the printing platform OCT data; Z Set_Height(i) Indicates the number of pixels that the printer moves downward in the Z direction relative to the front edge before printing when printing the i-th layer; Z Imaging_Print(i) is the surface point matrix of the i-th layer OCT data; Δz represents the spatial resolution in the Z direction of the OCT data.
[0026] In one embodiment, the defect states include normal extrusion, under-extrusion, over-extrusion, wire breakage, and wire drawing; and the defect states of the defect representation diagram are defined using different colors.
[0027] The specific criteria for judging whether the defect state in the defect representation diagram is a normal extrusion part are:
[0028] Thickness Target -error≤Thickness Print(i) ≤Thickness Target +error;
[0029] The specific criteria for judging whether the defect state in the defect representation diagram is under-extrusion are:
[0030] 0 <ThicknessPrint(i)<Thickness Target -error;
[0031] The specific criteria for judging whether the defect state in the defect representation diagram is an over-extrusion part are:
[0032] Thickness Print(i) Thickness Target +error;
[0033] The specific criteria for judging the broken wire portion of the defect status in the defect representation diagram are:
[0034] Thickness Print(i) =0 and Thickness Print(i) ≠0;
[0035] The specific criteria for judging whether the defect state in the defect representation diagram is the wire drawing part are:
[0036] Thickness Print(i) >0;
[0037] Thickness Tar get Indicates the target thickness of the i-th layer; error indicates the tolerance; Thickness Print(i) Indicates the actual thickness of the i-th layer; Thickness' print(i) Indicates the printing thickness outside the Gcode path planning of the i-th layer.
[0038] The defect state in the defect representation diagram is the construction of the wire drawing part:
[0039] First, the 2D target model mask is inverted to obtain image A; then the skeleton of the reconstructed OCT printing model is extracted and expanded to obtain image B; then, image A is multiplied with the reconstructed OCT printing model to obtain the reconstructed printing model outside the target path, and then the reconstructed printing model outside the target path is subjected to morphological operations. Finally, the pixel values of the connected domains in the obtained results that do not meet the set threshold condition (1 / 3 of the mean area of all connected domains) are set to 0 to obtain image C to obtain the wiredrawing defect.
[0040] One implementation method further includes performing an SSIM fidelity evaluation on the current layer after the defect repair in step (3).
[0041] In a second aspect, the present invention provides a 3D printing defect recognition system based on OCT and deep learning, comprising:
[0042] Dedicated workstation: Integrated print control and data processing software, responsible for managing print jobs and processing OCT data. The software implements 3D printing defect identification methods.
[0043] 3D mechanical motion components: ensure precise print head positioning and movement, supporting high-precision layered printing.
[0044] Printhead mounting arm and sensors: including temperature, pressure, and distance sensors, used to monitor printing conditions in real time and adjust printing parameters to optimize print quality.
[0045] Source Scanning OCT Module (SS-OCT): The OCT probe is installed next to the print head to monitor the printing process in situ and capture high-resolution printing defects and accuracy data.
[0046] Beneficial effects of the present invention:
[0047] (1) Improved Defect Detection Accuracy and Sensitivity: By combining OCT technology with deep learning algorithms, the present invention can accurately detect minute defects in the 3D printing process in real time, including broken wires, under-extrusion, over-extrusion, and wiredrawing, which are difficult to accurately identify using traditional detection methods. The present invention demonstrates greater applicability and effectiveness when processing complex or irregular models.
[0048] (2) Enhanced dynamic defect repair capabilities: By leveraging the ability to monitor and precisely locate defects in real time, the present invention can dynamically adjust printing parameters and print tip position to accurately repair identified defects. This dynamic adjustment and repair mechanism significantly improves the adaptability of the printing process and the consistency of print quality.
[0049] (3) Improving printing efficiency and reducing material waste: By optimizing printing parameters and repairing defects in real time, the present invention reduces printing failures and the need for reprinting due to defects, thereby improving printing efficiency and reducing material waste.
[0050] (4) Enhanced model fidelity and structural strength: By adopting the SSIM evaluation method, the present invention can not only visually ensure the high consistency between the printed model and the design model, but also ensure the integrity and strength of the printed structure through accurate defect repair, thereby improving the performance of the final product.
[0051] (5) Expanding the scope of application: The method and system of the present invention are not limited by the complexity of the model and can be widely used in various 3D printing scenarios, especially in the field of industrial manufacturing with high precision and high quality requirements.
[0052] In summary, the present invention not only significantly improves the efficiency and effectiveness of defect identification and repair in 3D printing technology, but also provides strong technical support for improving the quality and reliability of printed products. It has important practical value and broad market prospects. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 A method for generating a 2D target model provided by an embodiment of the present invention; wherein (a) a GCode script, the green and red dashed boxes represent the XY plane coordinate sequences of the first and second layers; (b) a single-layer 2D target model printing, the grayscale value represents the height of the 2D target model, and the distance between the red bars represents the width of the 2D target model; (c) an example of multi-layer 2D target model printing, where green represents the first layer and red represents the second layer.
[0054] Figure 2A method for generating a reconstructed printing model provided in an embodiment of the present invention; wherein (a) the 3D P-OCT result of the printing platform; (b) the 3D P-OCT result of the first layer; and (c) the reconstructed printing model of the first layer, including thickness information.
[0055] Figure 3 1. An example diagram of a method for producing labels (defect states) for a neural network provided in an embodiment of the present invention; wherein (a) a 2D target model; (b) a 2D target model mask; (c) a reconstructed printing model; (d) a reconstructed printing model within a target path; (e) an inverted 2D target model mask; (f) a result image obtained after skeleton extraction and expansion processing; (g) a filament drawing defect result; (h) a defect feature map: background (black), normal extrusion (green), under-extrusion (cyan), broken filament (dark blue), over-extrusion (yellow), and drawing (red); (i) a final reconstructed printing model inside and outside the target path; (j) a reconstructed printing model before broken filament repair; (k) a defect feature map before broken filament repair; (l) a reconstructed printing model after broken filament repair; and (m) a defect feature map after broken filament repair.
[0056] Figure 4 A diagram of a neural network architecture provided for an embodiment of the present invention.
[0057] Figure 5 A diagram showing defect detection results provided by an embodiment of the present invention; wherein (a1) is the reconstructed printing model, (a2) is the 2D target model, (a3) is the correct result, (a4) is the neural network prediction result, b1) is the reconstructed printing model, (b2) is the 2D target model, (b3) is the correct result, and (b4) is the neural network prediction result. DETAILED DESCRIPTION
[0058] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0059] The terms "including," "having," and any variations thereof, as used in the embodiments of the present invention are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or units is not limited to the listed steps or units, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to the process, method, product, or apparatus.
[0060] In order to effectively detect and correct defects in the printing process of complex and irregular models, this paper proposes a printing defect recognition method and system based on OCT and deep learning. The core of this method is to use Gcode path information to construct a two-dimensional 2D target model, which will serve as the benchmark for subsequent printing quality evaluation and defect detection. Figure 1 As shown, the process is divided into several key steps, each of which is designed to ensure that the generated standard model can accurately reflect the expected printing results, thereby providing a reliable comparison benchmark for defect detection.
[0061] Step (1), constructing a deep neural network, and training, testing and verifying it;
[0062] Step (2): Based on the OCT data collected by the OCT system, a 2D target model image based on the Gcode information and a reconstructed OCT printing model image of the current printing layer are obtained; the 2D target model image and the reconstructed OCT printing model image of the above printing layer are input into the trained, tested and verified deep neural network to obtain a defect representation map of the above printing layer.
[0063] Step (3): adjusting the printing parameters of the OCT system according to the defect representation diagram to repair the defect.
[0064] Furthermore, the step (1) mainly includes: defining an improved U-net network architecture as an existing U-net network, keeping the input and output sizes with the same resolution, while introducing the CBAM attention mechanism and constructing a dual-channel input.
[0065] Furthermore, the CBAM attention mechanism consists of the following components: Channel Attention: First, it passes through global average pooling and global maximum pooling, then passes through a fully connected layer (MLP) with shared weights, and finally applies a sigmoid activation function. Spatial Attention: Using the output of the previous channel attention, a 7×7 convolution kernel is applied, and then a sigmoid activation function is applied.
[0066] Furthermore, the CBAM attention mechanism and Dropout method are inserted successively after the DoubleConv layers from the second to the penultimate layer in the existing U-net network coding layer, that is, the CBAM attention mechanism module is added after the DoubleConv of each Down module and before the DoubleConv of the Up module; and Dropout regularization is added after the last convolution of each DoubleConv module.
[0067] Furthermore, the dual-channel input includes: a 2D target model image processed by channel stacking and a reconstructed OCT print model image, which provides a unique and information-rich dual-channel input for the neural network and can be applied to any complex print model architecture. Figure 3 (a) Generate 2D target model mask ( Figure 3 (b)), and compare the 2D target model mask with the reconstructed print model ( Figure 3 (c) Perform dot multiplication to obtain the reconstructed printing model within the target path ( Figure 3 (d)).
[0068] Furthermore, the acquisition of the 2D target model image specifically includes:
[0069] 1) Create a 2D target model space on the XY plane based on the field of view of the OCT system.
[0070] 2) Extract the XY coordinate sequence under the same Z coordinate from GCode.
[0071] 3) Generate a 2D printing path using the XY coordinate sequence based on the resolution of the OCT system data.
[0072] 4) Based on the printing information in the GCode and the 2D path, a 2D standard model diagram containing target printing parameters is generated. The target printing parameters mainly include printing pressure, printing speed, and printing layer thickness.
[0073] According to the data acquisition parameters of the OCT system, a 2D target model space is created on the XY plane. This step is fundamental and critical because it determines the spatial range and accuracy of the model generation. Subsequently, from GCode ( Figure 1 a, where layer1 represents the first layer and layer2 represents the second layer) extracts the XY coordinate sequence at the same Z coordinate. These coordinate sequences are the direct input for building the model and represent the expected movement path of the print head.
[0074] The Bresenham algorithm is used to interpolate line segments between consecutive coordinate points. This algorithm ensures path continuity and smoothness while generating an accurate 2D path based on the OCT resolution. This algorithm is a commonly used line drawing algorithm in image processing and is suitable for simulating continuous straight line paths within a discrete array of points.
[0075] Furthermore, the present invention uses optical coherence tomography (OCT) technology to reconstruct the printed model. Due to the characteristics of adjacent installation of the imaging probe and the print nozzle in OCT, the present invention adopts the "printing-imaging" alternating mode to perform three-dimensional data acquisition on the 3D printed bracket and reconstruct the 3D printed model. First, before printing begins, the coordinate system of the device is calibrated to ensure that it can be printed correctly according to the GCode instruction information; secondly, the basal layer data is collected by OCT and the device coordinates at the time of collection are recorded; then, the image coordinates of the basal layer are extracted based on the OCT data; thereafter, after printing starts, according to the penetration depth of the printing ink by OCT, after each printing of one or more layers, the bracket data is collected by OCT and the device coordinates at the time of collection are recorded, wherein the XY coordinates are consistent with the data acquisition coordinates of the printing platform, and the Z coordinate is adjusted according to the height of the printed bracket. Finally, surface point detection is performed on each group of OCT data and the position of the surface point under each XY coordinate in the three-dimensional image is recorded, and the thickness distribution of each round of printing structure is calculated in combination with the device coordinates during data collection as the reconstructed printing model map. Therefore, the reconstructed OCT printing model image generation step includes:
[0076] 1) Before printing, measure the printing platform height and calibrate the printing coordinates of the OCT system;
[0077] 2) Use the OCT system to collect OCT data of the printing platform and record the acquisition coordinates;
[0078] 3) After each layer is printed, the OCT system is used to collect OCT data of the printed stent in the current layer;
[0079] 4) Processing the OCT data collected in step 3) extracts the surface points of each OCT data, and then reconstructs the printed model according to the thickness distribution calculation formula. The thickness distribution calculation formula is:
[0080] Thickness Print(i) =(Z Imaging_Base +Z set_Height(i) -Z Imaging_Print(i) )×ΔZ
[0081] Thickness Print(i) represents the thickness distribution of the i-th layer; Z Imaging_Base is the surface point matrix of the printing platform OCT data; Z Set_Height(i) Indicates the number of pixels that the printer moves downward in the Z direction relative to the front edge before printing when printing the i-th layer; Z Imaging_Print(i) is the surface point matrix of the i-th layer OCT data; Δz represents the spatial resolution in the Z direction of the OCT data. Figure 2 (a) and (b) show the OCT imaging results of the printing platform and the first round of printed structures, respectively. Figure 2(c) Demonstrates the use of a custom thickness calculation formula to obtain a reconstructed print model image. Based on this method, during the printing process, the printed structure is imaged with OCT in an alternating "print-and-image" manner, and a reconstructed print model image is obtained, which is then used for subsequent print quality monitoring and defect detection.
[0082] Furthermore, according to the 2D target model ( Figure 3 (a)) and the reconstructed print model within the target path ( Figure 3 (d) The center path target thickness, actual thickness and tolerable error are used to define the defect status.
[0083] For example, the print status is defined as follows:
[0084] The defect states include normal extrusion, under-extrusion, over-extrusion, wire breakage, and wire drawing; the defect states of the defect representation diagram are defined using different colors.
[0085] The specific criteria for judging whether the defect state in the defect representation diagram is a normal extrusion part are:
[0086] Thickness Tar get -error≤Thickness Print(i) ≤Thickness Tar get +error;
[0087] The specific criteria for judging whether the defect state in the defect representation diagram is under-extrusion are:
[0088] 0 <Thickness Print(i) <Thickness Target -error;
[0089] The specific criteria for judging whether the defect state in the defect representation diagram is an over-extrusion part are:
[0090] Thickness Print(i) Thickness Target +error;
[0091] The specific criteria for judging the broken wire portion of the defect status in the defect representation diagram are:
[0092] Thickness Print(i) =0 and Thickness Target ≠0;
[0093] The specific criteria for judging whether the defect state in the defect representation diagram is the wire drawing part are:
[0094] Thickness Print(i) >0.
[0095] Thickness Target Indicates the target thickness of the i-th layer; error indicates the tolerance, which is 0.05mm in this embodiment; Thickness Print(i) Indicates the actual thickness of the i-th layer; Thickness' print(i) Indicates the printing thickness outside the Gcode path planning of the i-th layer.
[0096] The defect state in the defect representation diagram is the construction of the wire drawing part:
[0097] First, the 2D target model mask is inverted to obtain Figure 3 (e) Image A. Then, skeleton extraction was performed on the reconstructed OCT print model, the minimum branch length was set to 10, and a square structure element with a side length of 20 was used for expansion. Figure 3 (f) Image B; then Figure 3 (e) Image A and reconstructed OCT printed model Figure 3 (c) Perform dot multiplication to obtain the reconstructed print model outside the target path. Then, perform morphological corrosion on the image outside the reconstructed print model by using a linear structure element with a length of 3 and a direction of 90 degrees. Finally, set the pixel value of the connected domain in the result that does not meet the set threshold condition (1 / 3 of the average area of all connected domains) to 0. Figure 3 (g) Image C.
[0098] The background is black, the normal extrusion state is green, the under-extrusion state is cyan, the broken wire defect is represented by dark blue, the over-extrusion state is represented by yellow, and the drawing defect is represented by red.
[0099] Specifically, based on the registration of the 2D target model and the reconstructed print model, the normal extrusion, under-extrusion, over-extrusion, wire breakage and wire drawing states are identified according to the above judgment criteria, and different types of printing defects are displayed in the path-related defect representation diagram ( Figure 3 (h)). Among them, the defect representation diagram background is black, the normal extrusion state is green, the under-extrusion state is cyan, the broken wire defect is represented by dark blue, the over-extrusion state is represented by yellow, and the wire drawing defect is represented by red. Based on the defect representation diagram, the defect status and defect location can be obtained, especially for broken wire and under-extrusion defects. When the defect location is known, the printing result can be optimized by adjusting the printing parameters or the broken wire defect can be repaired by secondary printing. Among them, Figure 3 (i, j) show the reconstructed printing model with broken wire defects and defect representation diagram. Figure 3 (k) is the Gcode instruction for repairing the broken wire defect. Figure 3(l, m) are the reconstructed printing model and defect representation diagram after the second printing to repair the broken wire defect. Assuming that the target wire diameter is FS, the number of pixels occupied by FS is used as the window size for calculating SSIM. Finally, the average of all SSIM is taken as the print structure fidelity result. Among them, Figure 3 The fidelity of the reconstructed printed model shown in (j) is 0.8273, and the fidelity of the restored model is 0.9241 ( Figure 3 (k)), an improvement of 9.68%.
[0100] Furthermore, the step of repairing defects such as broken wire and under-extrusion further includes:
[0101] 1) Real-time monitoring: The neural network outputs a defect representation map and, based on the monitoring results, accurately locates defects to accurately identify the specific locations of defects such as broken wire and under-extrusion.
[0102] 2) Dynamic Adjustment: Based on the specific location of the defect, the system automatically calculates the optimal adjustment plan for the print head. This includes but is not limited to the print head's movement speed, direction adjustment, and possible height changes to ensure the print head accurately reaches the area requiring repair.
[0103] 3) Precision Repair: After completing dynamic adjustments, the system will perform corresponding repair procedures based on the defect type, such as adding material to fill the under-extruded part or reprinting the broken filament area to ensure the integrity and quality of the model.
[0104] 4) Restoration Verification: After the restoration is completed, a fidelity assessment is performed again to verify whether the restoration effect meets the expected standards and ensure the printing quality of each layer.
[0105] Furthermore, the hyperparameter selection also includes:
[0106] (1) Application of CUDA acceleration technology: To fully utilize computing resources and significantly reduce model training time, this paper uses CUDA technology for training acceleration. CUDA allows for direct use of NVIDIA GPUs for parallel computing, which can achieve acceleration effects of tens or even hundreds of times compared to traditional CPU training. During model training, batches of data are loaded and processed in parallel, greatly improving training efficiency.
[0107] (2) Dynamic learning rate adjustment: To address potential challenges during training, such as gradient vanishing or exploding, this paper adopts a dynamic learning rate adjustment strategy. By setting learning rate decay, the learning rate is gradually reduced after training reaches a certain stage, which helps the model converge more stably when approaching the optimal solution. In addition, the learning rate is adjusted based on performance feedback on the validation set to ensure that the model can learn at the most appropriate rate at different stages.
[0108] (3) Implementation of an early stopping mechanism: Considering the risk of overfitting, especially when training complex models on limited datasets, the present invention implements an early stopping mechanism. Specifically, the early stopping mechanism monitors the performance indicators on the validation set and terminates training early if there is no significant improvement in performance over several consecutive epochs. This not only prevents the model from overfitting on the training set, but also saves computing resources and improves training efficiency.
[0109] Furthermore, after the defect repair in step (3), the SSIM fidelity evaluation is also performed on the current layer after the defect repair. The fidelity evaluation uses the structural similarity index (SSIM) to analyze the model similarity, and the calculation formula for evaluating the print structure fidelity is:
[0110]
[0111] Where x and y represent the height images of the 2D target model and the actual printed bracket, respectively, and μ x and μ y represent the mean values of x and y, σ x and σ y represent the standard deviation of x and y, σ xy represents the covariance of x and y, and c1 and c2 are constants used to increase stability. Assuming the target wire diameter is FS, the number of pixels occupied by FS is used as the window size for calculating SSIM. Finally, the average of all SSIMs is taken as the result of printed structure fidelity.
[0112] The model used in the present invention emphasizes the consistency of input and output sizes in order to maintain the integrity of spatial information during the defect detection process. The input layer of the model receives a composite image consisting of two single channels, one of which is a printed model image reconstructed based on OCT, and the other is a 2D target model image generated based on G-code information. This design enables the model to comprehensively utilize the information in the two images to improve the accuracy of defect detection. The output layer is designed to generate a single-channel multi-classification image with the same size as the input image, and each pixel of the single channel corresponds to a defect type, thereby achieving pixel-level classification. Figure 4 As shown, the model structure is as follows:
[0113] (1) Input layer: The model accepts a dual-channel image as input. The first channel is the OCT-reconstructed printed model, and the second channel is the corresponding G-code 2D target model image. This dual-channel input strategy aims to provide the network with richer spatial and geometric information for more accurate defect identification.
[0114] (2) Convolutional layers: Multiple convolutional layers are used to extract image features. Each convolutional layer is followed by a ReLU activation function to introduce nonlinearity, allowing the network to learn more complex feature representations. BatchNormalization is used after each convolutional block to normalize the data to accelerate the training process and improve model stability.
[0115] (3) Attention Mechanism: The CBAM attention module is integrated to first reshape the importance of feature channels through the channel attention mechanism, and then focus on the most informative areas in the image through the spatial attention mechanism. This step helps the model pay more attention to defect features, thereby improving the accuracy of defect detection.
[0116] (4) Dropout layer: A dropout layer is introduced after some convolution blocks to randomly “drop” some neuron connections in a probabilistic manner to prevent overfitting of the model and enhance the generalization ability of the model. The dropout rate is uniformly set to 0.1.
[0117] (5) Upsampling and skip connections: Upsampling layers are used in the expansion path of the model to gradually restore the feature maps to their original size. At the same time, skip connections are used to concatenate the feature maps in the contraction path with those in the expansion path to preserve more detailed information. The upsampling operation can use bilinear interpolation or transposed convolution depending on the setting of the bilinear parameter.
[0118] (6) Output layer: Finally, a 1x1 convolutional layer is used to map the feature map to the final classification map. Each pixel of the output image corresponds to one of six different defect types, including background, broken wire, under-extrusion, standard, accumulation, and drawing.
[0119] The actual defect detection effect of the improved U-net network model constructed by the present invention is as follows: Figure 5 As shown in the figure, OCT-based reconstructed print model data with broken wires, under-extrusion, buildup, and wiredrawing were inspected. Experimental results show that the present invention demonstrates excellent performance in accurately identifying and classifying defects in 3D printing, with average accuracy and precision of 95.2% and 93.1% respectively. Figure 5 (a) and (b) show the reconstructed printing model data without the improved U-net neural network training. Figure 5 (a) Although the improved U-net neural network was trained on the same reconstructed printing model data, the defect types it faced were different. Figure 5 (a1) is the reconstructed printing model, (a2) is the 2D target model, (a3) is the correct result, and (a4) is the improved U-net neural network prediction result; Figure 5(b) shows the improved U-net neural network for the new reconstructed printing model data, and the detection effect is equally accurate. Figure 5 (b1) Reconstructed printing model, (b2) is the 2D target model, (b3) is the correct result, and (b4) is the improved U-net neural network prediction result.
[0120] The present invention further provides a printing defect recognition system based on OCT and deep learning, comprising:
[0121] Dedicated workstation: Integrated print control and data processing software, responsible for managing print jobs and processing OCT data. The software implements 3D printing defect identification methods.
[0122] 3D mechanical motion components: ensure precise print head positioning and movement, supporting high-precision layered printing.
[0123] Printhead mounting arm and sensors: including temperature, pressure, and distance sensors, used to monitor printing conditions in real time and adjust printing parameters to optimize print quality.
[0124] Source Scanning OCT Module (SS-OCT): The OCT probe is installed next to the print head to monitor the printing process in situ and capture high-resolution printing defects and accuracy data.
Claims
1. A 3D printing defect recognition method based on OCT and deep learning, characterized by The steps are as follows: Step (1), build a deep neural network, and train, test and verify it; 1-1 Obtain a 2D target model image based on Gcode information and a reconstructed OCT print model image of the same print layer, mark the defect labels, and then divide them into training set, test set, and validation set; The defect label adopts a defect representation diagram defined by at least one defect state; The acquisition of the 2D target model image specifically includes: 1) Create a 2D target model space on the XY plane based on the field of view of the OCT system; 2) Extract the XY coordinate sequence under the same Z coordinate from GCode; 3) Generate a 2D printing path using the XY coordinate sequence based on the resolution of the OCT system data; 4) Generate a 2D standard model diagram containing target printing parameters based on the printing information in the GCode and the 2D path; The acquisition of the reconstructed OCT printing model image specifically includes: 1) Before printing, measure the printing platform height and calibrate the printing coordinates of the OCT system; 2) Use the OCT system to collect OCT data from the printing platform and record the acquisition coordinates; 3) After each layer is printed, the OCT system is used to collect OCT data of the printed stent in the current layer; 4) Processing the OCT data collected in step 3) to extract surface points of each OCT data, and then reconstructing the printed model based on the thickness distribution calculation formula; The thickness distribution calculation formula is: ; in The surface point matrix of the printing platform OCT data; Indicates printing When printing a layer, the number of pixels that the printer moves down in the Z direction relative to the leading edge before printing begins; For the Surface point matrix of slice OCT data; Indicates the spatial resolution in the Z direction of OCT data; 1-2 Build a deep neural network and train, test and validate it; The deep neural network adopts the U-net network that introduces the CBAM attention mechanism; Step (2): obtaining a 2D target model image based on Gcode information and a reconstructed OCT printing model image of the current printing layer according to the OCT data collected by the OCT system; inputting the 2D target model image and the reconstructed OCT printing model image of the above printing layer into the deep neural network after training, testing and verification to obtain a defect representation map of the above printing layer; Step (3): Adjust the printing parameters of the OCT system according to the defect representation diagram to repair the defect.
2. The method according to claim 1, characterized in that The U-net network that introduces the CBAM attention mechanism changes the single-channel input of the U-net basic framework to a dual-channel input, and inserts the CBAM attention mechanism and the Dropout method sequentially after the DoubleConv layer from the second to the second-to-last layer in the encoding layer; The dual-channel input refers to performing channel stacking processing on the 2D target model image and the reconstructed OCT printing model image.
3. The method according to claim 1, characterized in that The defect states include normal extrusion, under-extrusion, over-extrusion, wire breakage, and wire drawing; the defect states of the defect representation diagram are defined using different colors.
4. The method according to claim 3, characterized in that The specific criteria for judging whether the defect state in the defect representation diagram is a normal extrusion part are: ; The specific criteria for judging whether the defect state in the defect representation diagram is under-extrusion are: ; The specific criteria for judging whether the defect state in the defect representation diagram is an over-extrusion part are: ; The specific criteria for judging the broken wire portion of the defect status in the defect representation diagram are: and ; The specific criteria for judging whether the defect state in the defect representation diagram is the wire drawing part are: ; in Indicates the set Layer target thickness; error indicates tolerance; Indicates the The actual thickness of the layer; Indicates the Print thickness outside the Gcode path planning layer.
5. The method according to claim 4, characterized in that The defect state in the defect representation diagram is the construction of the wire drawing part: First, the 2D target model mask is inverted to obtain image A. Then, the skeleton of the reconstructed OCT printing model is extracted and expanded to obtain image B. Next, image A is multiplied with the reconstructed OCT printing model to obtain the reconstructed printing model outside the target path. Morphological operations are then performed on the reconstructed printing model outside the target path. Finally, the pixel values of the connected domains whose areas do not meet the set threshold conditions are set to 0 to obtain image C to determine the wiredrawing defects.
6. The method according to claim 1, characterized in that After the defect is repaired in step (3), the SSIM fidelity evaluation of the current layer after the defect repair is also included.
7. A 3D printing defect recognition system based on OCT and deep learning, characterized by include: Dedicated workstation: integrated with print control and data processing software, responsible for managing print tasks and processing OCT data; The software executes the method according to any one of claims 1 to 6; 3D mechanical motion components: ensure precise print head positioning and movement, and support layered printing; Printhead mounting arm and sensor: used to monitor printing conditions in real time and adjust printing parameters to optimize print quality; Light source scanning OCT module: The OCT probe is installed next to the print head and is used to monitor the printing process in situ to capture printing defects and accuracy data.
Citation Information
Patent Citations
Synchronous microtomography online monitoring method and system for three-dimensional printing
CN107498874A
3D printer and 3D printing method
CN110053254A