Real-time defect detection for FDM 3D printing using lightweight model deployment | Research Square window.SnipcartSettings = { analytics: { enabled: false } }; (function() { var accessVector = localStorage.getItem('access_vector') || ''; window.dataLayer = window.dataLayer || []; if (accessVector) { window.dataLayer.push({ user: { profile: { profileInfo: { snid: accessVector } } } }); } })(); (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-K279D39R'); Browse Preprints In Review Journals COVID-19 Preprints AJE Video Bytes Research Tools Research Promotion AJE Professional Editing AJE Rubriq About Preprint Platform In Review Editorial Policies Our Team Advisory Board Help Center Sign In Submit a Preprint Cite Share Download PDF Research Article Real-time defect detection for FDM 3D printing using lightweight model deployment WenJing Hu, Chen Chang, Shaohui Su, Jian Zhang, An Zhu This is a preprint; it has not been peer reviewed by a journal. https://doi.org/ 10.21203/rs.3.rs-4380689/v1 This work is licensed under a CC BY 4.0 License Status: Published Journal Publication published 17 Sep, 2024 Read the published version in The International Journal of Advanced Manufacturing Technology → Version 1 posted 5 You are reading this latest preprint version Abstract FDM 3D printing is one of the most widely used additive manufacturing methods, bringing great convenience to production manufacturing. However, various printing defects may occur during the printing process due to human factors or printer-related issues. Timely detection of defects and halting printing becomes a scenario of significant practical importance. This paper first analyzes the causes of the five most common defects in FDM 3D printing, and a defect dataset is created by deliberately designing defects. Subsequently, a real-time defect detection system for FDM 3D printing, based on an improved YOLOv8 detection head, is developed. By employing an optimization method using Group Convolution to share parameters, the detection head is lightweight, resulting in better model performance. Experimental results demonstrate that the mAP50 of the improved YOLOv8 model reaches 97.5%, with an 18.1% increase in FPS and a 32.9% reduction in GFLOPs. This enhancement maintains comparable detection accuracy to the original model while achieving faster detection speed and lower computational requirements. The improved model is integrated into the detection system as the detection model, and through testing, the real-time detection system promptly and accurately identifies and alerts any occurring defects. The practical significance of this system lies in its ability to enhance production efficiency, reduce resource wastage due to defective printing, and improve product quality and manufacturing safety, thereby providing strong support for the application of visual inspection technology in FDM 3D printing. FDM 3D printing Real-time defect detection Object detection Group Convolution Lightweight detection head Figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Figure 8 Figure 9 Figure 10 Figure 11 Figure 12 Figure 13 1. Introduction In recent years, 3D printing technology has become an important innovation in the manufacturing field and is widely used in industry, medicine and other fields [ 1 ][ 2 ]. Among these technologies, Fused Deposition Modeling (FDM) stands out due to its simplicity, speed, and cost-effectiveness, making it excel in areas such as rapid prototyping, personalized customization, and small-batch production [ 3 ][ 4 ]. However, during the printing process, operational faults caused by improper processing parameter settings and external disturbances, as well as health-related faults stemming from mechanical damage to the printer, often lead to destructive defects in printed parts [ 5 – 7 ]. With the continuous expansion of its applications, quality control and defect detection in FDM 3D printing have become one of the key issues that urgently need to be addressed [ 8 ]. Currently, most detection methods involve quality checks after printing completion, which cannot detect and identify issues in real time during the printing process. Such detection methods undoubtedly result in the wastage of time and materials. Researchers have conducted numerous studies to address the defects occurring during the printing process, aiming to rectify issues leading to product non-conformities. In detection, non-destructive testing is a widely employed method in FDM 3D printing, where error detection mechanisms using cameras provide feasibility for remote supervision and early fault detection [ 9 ]. Bhavsar et al. [ 10 ] utilized discrete wavelet transform to analyze the differences in vibration acoustic signals of sensors during FDM 3D printing, aiming to detect the first layer filament deposition process, thereby achieving detection of first layer bonding quality. Machine learning finds extensive application in defect detection, as demonstrated by Lopes et al. [ 11 ], who employed piezoelectric microphones, support vector machines (SVMs), and neural networks for machine state monitoring in FDM 3D printing. Through signal processing and feature extraction techniques such as RMS values and spectral analysis, the study identified raw signal patterns associated with different machine conditions (such as normal operation, extruder blockages, and filament shortages). Classification using machine learning algorithms like SVMs and neural networks, alongside signal filtering, can enhance model accuracy. Zhao et al. [ 12 ] proposed a novel online inspection technique using stripe projection for 3D printing, aiming to enhance the stability and quality of additive manufacturing processes. The proposed method involves region-based defect detection, improving detection accuracy by analyzing sub-regions. By combining Voxel Cloud Connectivity Segmentation (VCCS) and Fast Point Feature Histograms (FPFH), the printing area is divided into multiple sub-regions for evaluation. With the advancement of visual technology, defect detection methods are not limited to analyzing vibration signals on sensors alone. Li et al. [ 13 ], for instance, combined visual and sensor-based defect classification methods, monitoring sensor signals (temperature and vibration data) and interlayer images during the printing process, establishing two machine learning models, and merging their predictive results to enhance defect classification accuracy. Yean et al. [ 14 ] combined AlexNet convolutional neural networks with support vector machine (SVM) classifiers for detecting spaghetti and stringing defects, achieving desirable accuracy in defect classification. Shen et al. [ 15 ], in the printing process of a six-degree-of-freedom robotic FDM printer, altered the detection field of view using surface vectors, effectively identifying defects based on layer compression structures and introduced mathematical matrix representation of defects for detecting printing defects based on geometric shapes and area distributions. With the advancement of 3D technology, the detection of FDM 3D printing defects has become more comprehensive. Utilizing 3D point cloud for defect detection provides detailed spatial information, enhancing defect identification. Zhao et al. [ 16 ] extracted potential defect areas using MBH and INRoPS feature descriptors, along with precise defect detection based on neighborhood point calculations, addressing the limitations of existing defect detection methods by providing more accurate and reliable results. Holzmond et al. [ 17 ] employed 3D Digital Image Correlation (3D-DIC) to transform image technology into three-dimensional data, comparing printed geometries with computer models for in-situ error detection, demonstrating the effectiveness of 3D-DIC systems in detecting local and global defects in test cases using Fused Filament Fabrication (FFF) 3D printers. Non-destructive testing using devices such as cameras enables remote supervision and early fault detection, facilitating early problem detection and resolution without destructive operations. Machine learning algorithms such as Support Vector Machines (SVMs) and neural networks effectively classify and recognize signals, enhancing detection accuracy and efficiency. Technologies like 3D point clouds provide detailed spatial information, enabling more accurate defect detection and description. However, some methods involve complex equipment and technologies, requiring specialized knowledge and skills for operation and maintenance, thus increasing implementation complexity. Some methods rely on specific equipment or environments, which may limit their applicability to practical scenarios, reducing their generality. With the rapid development of neural networks, they have found excellent applications in detecting defects in FDM 3D printing. A multi-sensor data acquisition system is employed to collect real-time signals such as vibration, current, and sound sensors during FDM 3D printing. These captured data are then analyzed in the time domain and frequency domain to create feature vectors for training CNN models, which are subsequently used for defect detection [ 18 ]. In addition to vibration signals, image signal acquisition is more convenient, faster, and cost-effective. A diverse set of image data, including various error levels and printing geometries, is required for training CNNs to ensure the system's generalization and effectiveness [ 19 ]. To make the detection process real-time, Zhang et al. [ 20 ] proposed a method using machine vision and convolutional neural networks (CNNs) to detect multi-axis FDM printing defects. Their self-built CNN network achieved an 83.1% classification accuracy for interlayer delamination defects. Farhan et al. [ 21 ] developed a CNN-deep learning model to detect real-time defects in 3D printing, such as inconsistent extrusion, weak infill, lack of support, or sagging. Using image detection methods, neural network models have demonstrated simplicity in data collection and the ability to detect defects in printing in real time. Deep learning methods are currently widely applied and demonstrate excellent performance in classification, object detection, and segmentation tasks. In FDM 3D printing defect detection, object detection methods are highly favored because they can identify defect types and locations. Zhang et al. [ 22 ] improved Faster R-CNN using an adaptive defect detection method based on the K-medoids clustering algorithm to detect lattice structures in CT slices of 3D printing. Xu et al. [ 23 ] replaced the backbone structure of YOLO v4 with MobileNetV2 as an improved model to recognize defects in FDM 3D printing. Paraskevoudis et al. [ 24 ] used an SSD model to analyze video clips to identify defects during the printing process, especially stringing defects. Kim et al. [ 25 ] discussed a system depth transfer learning method based on a small image dataset for monitoring spaghetti defects in Fused Deposition Modeling (FDM) printers. Image signal acquisition is more convenient and faster, and through image processing techniques, status and defect information during the printing process can be intuitively obtained. In FDM 3D printing defect detection, deep learning methods, due to their deeper network structures, achieve higher detection accuracy compared to CNN methods, and exhibit stronger generalization capabilities. Therefore, the application of deep learning methods in FDM 3D printing defect detection is highly significant. Currently, research primarily involves collecting images of each layer of the print head during printing to determine if defects exist, or analyzing print images collected from above the printed part. However, this method has some drawbacks. Firstly, collecting detailed images of each layer, as done by Shen et al. [ 15 ], involves enhancing the image contrast using histogram equalization techniques, converting the original image to a binary image through local binary patterns, and finally applying median filtering to preserve sharp signal changes and eliminate pulse noise. After these cumbersome operations, a mathematical matrix composed of central coordinates, aspect ratio, and area distribution is introduced to represent defects. Secondly, as Kaisar et al. [ 26 ] demonstrated using images captured by a camera above the printed part, there remains an issue of only being able to detect misalignment and over-extrusion, rather than comprehensively detecting major defects during the printing process. The proposed approach in this paper suggests capturing images directly in front of the printed part, which offers significant advantages. Firstly, it reduces the difficulty of image collection, as it doesn't require special or complex equipment installation positions—only clear images need to be captured. Secondly, capturing defect images from the front can encompass the most common defects, making it more versatile. In FDM 3D printing, defects can be categorized into single-layer defects and overall defects [ 27 ][ 28 ]. Single-layer defects include warping, stringing, bubbling, collapsing, wrinkling, interlayer delamination, and missing filament. Overall defects encompass sagging, warping, interlayer cracking, collapsing, overheating deformation, and layer misalignment. This paper aims to research and implement a defect detection system for FDM 3D printing based on an improved detection head using YOLOv8 for object detection. The objective is to comprehend real-time printing data during the printing process and promptly address any printing issues. By detecting common printing defects, the system ensures the quality of printed parts while reducing the waste of printing time and materials. We analyzed the formation mechanisms of common defects in the FDM 3D printing process, including warping, platform detachment, layer misalignment, interlayer delamination, and stringing. We used artificially generated defect images as the training dataset and improved the detection head of YOLOv8 to enhance detection performance, achieving automatic detection and classification of surface defects in printed parts. By comparing five improved detection heads, we sought the optimal improvement scheme and demonstrated the superiority of our improvement approach over conventional target detection methods by comparing the improved model with other mainstream target detection models. Additionally, we will establish a comprehensive experimental platform to validate the effectiveness and feasibility of the proposed method and explore its application prospects in practical production. The research findings of this paper will not only provide technical support for improving the quality and production efficiency of FDM 3D printing but also serve as a reference for defect detection issues in other similar application scenarios. It holds both theoretical and practical value. 2. Production of data sets 2.1 Defect types and causes FDM printers can encounter various defects during the printing process due to printing environment and parameter settings. Among the most common defects are warping, cracking, stringing, layer shifting, and off-platform (Fig. 1 ). Warping: This refers to the upward bending of the bottom edge of the printed object during printing, until it is no longer level with the print bed. This can lead to horizontal cracks at the top and even cause the printed object to detach from the print bed. Warping issues are primarily due to the natural characteristics of plastic materials. When materials like ABS or PLA cool down, they undergo slight shrinkage, and if the cooling process occurs too rapidly, warping issues can arise. Cracking: This refers to the poor connection between the layers of a part, causing them to separate. This issue may arise from two different reasons: Firstly, poor adhesion between layers, where layers fail to properly stick together. Poor adhesion is often caused by low printing temperatures, which can be addressed by increasing the printing temperature or reducing the layer fan speed. Secondly, thermal contraction occurs when the layers adhere well to each other, but temperature differences between different parts of the part result in deformation, leading to the separation of certain layers. Finally, abnormal up and down movements of the print platform during printing can result in significant gaps appearing in a particular layer of the printed part. Stringing: This refers to the residual filament-like objects left behind by the extruder when it moves across open spaces. The main reasons for stringing are as follows: Insufficient retraction distance: One of the most critical settings for retraction is the retraction distance, which determines how much filament is pulled back from the nozzle during retraction. Typically, the more filament is retracted from the nozzle, the less noticeable the stringing. Retraction speed too slow: Another important setting for retraction is the retraction speed, which determines how quickly the filament is pulled away. Temperature too high: If the temperature of the extruder is too high, the filament inside the nozzle becomes very viscous and tends to flow out of the nozzle easily. However, if the temperature is too low, it can be difficult for the filament to be extruded. Excessive travel distance without printing: The travel distance also has a significant impact on stringing. Short travel distances may not provide enough time for the melted filament to flow out of the nozzle, while long travel distances are more likely to cause stringing. Layer shifting: This refers to the occurrence of a layer being offset during the printing process. Most printers use stepper motors to drive machine movement, meaning the printer cannot detect the position of the print head. However, external forces or significant resistance can cause misalignment of the print head, and the printer lacks detection and correction measures, resulting in misalignment or displacement of the printed product. The reasons for layer misalignment are as follows:Excssive movement speed of the print head: If the print speed or travel speed exceeds the speed that the stepper motor can handle, misalignment issues may occur. Mechanical issues: Most machines utilize belt-driven mechanisms, and over time, the belts may elongate and become looser, leading to prolonged slipping off the pulley. Electronic issues: Insufficient power supply current to the stepper motor can result in inadequate force to overcome resistance. External forces: External forces pulling or tugging can cause displacement or misalignment, such as improper placement of consumables or extruder power lines, leading to pulling or entangling with other objects, resulting in layer shifting. Off-platform: This refers to the scenario where the printed object fails to adhere firmly to the heated bed during the printing process, resulting in chaotic filament patterns. This often occurs when the first layer of material fails to adhere properly to the heated bed. The reasons for this may include the nozzle being too far from the bed, preventing proper adhesion of the filament to the bed; printing speed being too fast, causing the filament to fail to adhere to the bed promptly; or the bed temperature being too low, causing the extruded filament to shrink upon cooling, leading to poor adhesion. The reasons for the occurrence of printing defects during the printing process also serve as the foundation for creating the printing dataset. The dataset creation in this study involved deliberately designing incorrect printing parameters and printing environments. By adjusting the temperature difference between the print head and the print bed, the occurrence of warping and platform detachment can be controlled: in this study, warping could occur when the print head was set to 220°C and the print bed to 30°C. Off-platform could occur when the print head was set to 220°C and the print bed was at room temperature. Pausing the print and moving the print bed during printing could result in layer shifting. Pausing the print and adjusting the print bed height during printing could result in cracking. Disabling retraction or adjusting the retraction distance to 1mm in the printing software could result in stringing. By comparing artificially induced printing defects with spontaneously occurring ones, it is observed that artificially induced printing defects are essentially consistent with spontaneously occurring ones since they are designed experiments based on the causes of printing defects. Artificially induced printing defects help address the scarcity of defect data caused by the limited occurrence and randomness of defects, thus significantly alleviating the difficulty in creating the dataset. 2.2 Image data collection The real-time 3D printing process image acquisition device designed in this study is shown in Fig. 2 . (a) is PLA printing material. PLA material exhibits good thermal stability and solvent resistance, with processing temperatures ranging from 170 to 230°C, and the final product has good heat resistance. (b) is the Creality Ender 3 FDM 3D printer, with a maximum print size of 220220250mm, a maximum print speed of 180mm/s, a print accuracy of ± 0.1mm, a nozzle diameter of 0.4mm, and a layer thickness of 0.1-0.35mm. (c) is a ring light source used to provide supplementary lighting for industrial cameras. In this paper, we preferred an adjustable brightness and color temperature LED ring light source to obtain 3D printed part images with uniform brightness and no shadows. (d) is the 1/1.8" 30mm 6MP FA lens from Hikvision, with model number MVL-HF3028M-6MPE. (e) is a 6-megapixel industrial line scan camera from Hikvision Robotics, model MV-CS060-10GC. The camera transmits images via a Gigabit Ethernet interface, enabling fast real-time data transfer with a frame rate of up to 19.1 fps at full resolution. It is used for real-time image acquisition of the 3D printing process with a real-time image acquisition device. 2.3 Data set construction and analysis Data was collected using a data acquisition device, resulting in a total of 294 images. Among them, there were 50 images of layer shifting, 54 images of cracking, 58 images of stringing, 72 images of warping, and 60 images of off-platform, totaling 294 images. The image size in the dataset is 3072×2048. Since the color of the images has minimal impact on defect detection, all images were converted to grayscale to reduce computational complexity. The performance of deep learning algorithms typically depends on having a sufficient number of training samples to provide an adequate representation of 3D printing defect features. With the limited samples available in the 3D printing defect dataset, overfitting during the training process can occur, making it difficult to detect new 3D printing defects effectively. Creating a comprehensive defect dataset requires a considerable amount of effort. However, utilizing common data augmentation techniques can achieve similar results. In this study, image enhancement methods were employed to improve the generalization ability of the deep learning model. The enhanced results, as shown in Fig. 3 , yielded a total of 1176 augmented images. Image Rotation: Image rotation augmentation is employed to enhance the dataset. This involves rotating the original image around the center of the image to generate new images. Elastic Transformation: Random standard deviations within the (-1, 1) interval are applied to each dimension of the pixel points. Gaussian filtering with a (0, sigma) filter is then performed on the deviation matrices for each dimension. Finally, the deviation range is controlled using the magnification coefficient alpha. This paper follows the widely accepted practice of dataset partitioning using an 8:1:1 ratio. This ensures the consistency and comparability of the evaluation method, contributing to the robustness and reliability of the results. By randomly dividing the dataset into three groups with an 8:1:1 ratio, we obtained 940 images in the training set, 118 images in the test set, and 118 images in the validation set, ensuring balanced distribution. This method avoids bias and overfitting while providing representative data distributions for training, validation, and testing. 3. Improvement of detection algorithm 3.1 YOLOv8 network structure YOLOv8 [ 22 ], released as a significant update to YOLOv5 by Ultralytics in 2023, introduces new features and improvements to enhance performance and flexibility based on the historical versions of the YOLO series. It offers models at different scales (N/S/M/L/X) based on scaling coefficients to meet various scene requirements. The backbone network and Neck part may draw inspiration from the YOLOv7 ELAN design philosophy, replacing the C3 structure of YOLOv5 with a more gradient-flow-rich C2f structure. There are significant changes in the Head part compared to YOLOv5, where it adopts the mainstream decoupled head structure, separating classification and detection heads, and transitioning from Anchor-Based to Anchor-Free. Loss computation employs the task aligned assigner positive sample allocation strategy and introduces distribution focal loss. The YOLOv8 model comprises five different versions: YOLOv8n, YOLOv8s, YOLOv8m, YOLOv8l, and YOLOv8x, with increasing model sizes among these versions. Considering the balance between real-time monitoring speed and subsequent model embedding in embedded devices, we opt for YOLOv8n as the baseline model for this study. 3.2 Improvement methods for detection head In the YOLO series of algorithms, the detection head is a crucial component responsible for outputting information about the location and category of targets. It typically utilizes bounding boxes to represent the position of targets, which include coordinates such as the top-left and bottom-right corners, along with associated size information. Moreover, it outputs a vector of class scores, with each score indicating the confidence level for the corresponding category. Usually, the length of this vector is equal to the number of categories in the dataset, allowing the model to perform classification for each category. In YOLO, the detection head is typically connected to different levels of the convolutional neural network to extract information from different feature maps. This helps the model consider various scales and semantic information of the image simultaneously, thereby improving detection performance. The detection head plays a critical role in the YOLO algorithm, as it is responsible for predicting the location and category information of targets from input images, enabling the model to efficiently and accurately perform object detection tasks in a single forward pass. YOLOv8 introduces a decoupled head structure, separating the classification and detection heads, which is currently a mainstream approach. However, this change also increases the computational complexity of the head section, as illustrated in Fig. 5 . Compared to the detection head of YOLOv5, the detection head of YOLOv8 has approximately 60 times more parameters, accounting for nearly 1/5 of the total computational load of YOLOv8. The computational load of the detection head directly affects the detection speed of the model. Moreover, reducing the computational requirements of the lightweight model can significantly enhance the portability of the entire detection system. Therefore, improving the detection head in the head section to maintain detection accuracy while significantly enhancing detection speed and lightweight model is a problem addressed in this study. As shown in Fig. 4 , the detection head of YOLOv8 consists of two branches, each utilizing two 3x3 convolutions (Conv) and one 1x1 convolution (Conv2d) to extract information, and finally calculate the bounding box loss and classification loss separately. However, YOLOv8 has three identical detection heads, which is the reason for the high computational demand for the detection head in YOLOv8. In light of this, as illustrated in Fig. 5 (a), the parameters of the first two 3x3 convolutions (Conv) can be shared, reducing the number of 3x3 convolutions (Conv) in the entire detection head from 4 to 2, resulting in a significant reduction in the parameter count. Alternatively, as shown in Fig. 5 (b), the two shared 3x3 convolutions (Conv) can be replaced with just one. This way, the number of 3x3 convolutions (Conv) in the detection head of the entire YOLOv8 model is reduced from 12 to 3, leading to a substantial decrease in the computational demand of the detection head. Group Convolution is a highly effective method for reducing the computational cost of convolutional operations, initially introduced in AlexNet. It introduces the concept of groups in convolution operations, allowing for more flexible handling of inputs and parameters. Typically, convolution operations process all channels of the input tensor and all filters simultaneously. In contrast, group convolution divides the channels of the input tensor into multiple groups, with each group sharing parameters. This reduces the number of parameters and computational costs significantly. As shown in Fig. 6 , the left side represents non-grouped convolution. In traditional convolutional operations, each convolutional kernel convolves with all channels of the input tensor, sharing the same set of parameters. Therefore, the total number of parameters required is: $$\begin{array}{c}n={k}^{2}{c}_{1}{c}_{2}\#\left(1\right)\end{array}$$ On the right side, grouped convolution is employed, where the channels of the input tensor are evenly divided into g groups, with each group containing c/g channels. Then, each group's channels are convolved with a portion of the convolutional kernels, where channels sharing the same convolutional kernel belong to the same group. Therefore, the total number of parameters required is: $$\begin{array}{c}n=\frac{{k}^{2}{c}_{1}{c}_{2}}{g}\#\left(2\right)\end{array}$$ We introduce GroupConv(Group Convolution) into the detection head of YOLOv8. Due to parameter sharing within each group, this helps to reduce model complexity and computational costs, as depicted in Fig. 7 . Additionally, as GroupConv divides the input tensor channels into multiple groups, the convolutional operations within each group can be performed in parallel, thereby improving network parallelism to some extent, which accelerates both training and detection speeds. Similarly, both convolutions can be replaced entirely with GroupConv, or only one GroupConv can be retained. 3.3 Evaluation standards In this study, Precision (P), Recall (R), Mean Average Precision (mAP), and F1 score are utilized to accurately evaluate the detection performance of the model. Precision (P) represents the proportion of correctly predicted positive samples to all samples predicted as positive. The calculation formula is as follows: $$\begin{array}{c}Precision=\frac{TP}{TP+FP}\times 100\%\#\left(3\right)\end{array}$$ Recall (R) represents the proportion of correctly predicted positive samples to all actual positive samples. The calculation formula is: $$\begin{array}{c}Recall=\frac{TP}{TP+FN}\times 100\%\#\left(4\right)\end{array}$$ Where TP represents True Positives, FP represents False Positives, and FN represents False Negatives. F1 score is a measure that combines precision and recall, it is the harmonic mean of precision and recall. The calculation formula is: $$\begin{array}{c}F1=\frac{2\times Precision\times Recall}{Precision+Recall}\times 100\%\#\left(5\right)\end{array}$$ In object detection, AP typically refers to the area under the Precision-Recall curve, providing a single value that encapsulates both precision and recall performance for evaluating the model comprehensively. In multi-class object detection tasks, mAP represents the average of AP values across all classes. The calculation formula is: $$\begin{array}{c}AP={\int }_{0}^{1}PR dR\times 100\%\#(6)\end{array}$$ $$\begin{array}{c}mAP=\frac{1}{C}\sum _{i=1}^{C}A{P}_{i}\#(7)\end{array}$$ In this study, detection speed and model size are also two important metrics. We use Frames Per Second (FPS) to evaluate detection speed, Parameters to evaluate model size, and Floating Point Operations (FLOPs) to measure model complexity (1GFLOPs = 1 billion floating point operations). Detection speed is related to the time for preprocessing, inference, and post-processing of images. The FPS represents the number of frames the model can process per second. A higher FPS means the model can process inputs faster. The calculation method for convolutional layer FLOPs is: $$\begin{array}{c}FLOPs=2\times {kerne{l}_{size}}^{2}\times inpu{t}_{channels}\times outpu{t}_{channels}\times outpu{t}_{size}\#(8)\end{array}$$ 4. Experimental results and analysis 4.1 Experimental platform and parameter settings To achieve faster training and better training results, as well as to approximate the performance on low-computational platforms when deployed in practice, this study utilized different hardware platforms for training and testing, as shown in Table 1 . The training parameters for this experiment are outlined in Table 2 . Table 1 Training and testing platform conditions Hardware and software conditions train test CPU Intel(R) Xeon(R) Platinum 8255C Intel(R) Core(TM) i7-8750H GPU RTX 2080 Ti(11GB) RTX 1050Ti (4GB) RAM 40GB 16GB Operating system Ubuntu20.4 Windows11 Compiled language python3.8 python3.8 Deep learning framework PyTorch 1.12 PyTorch 1.12 Table 2 Training parameter table Parameter Meaning Value Epochs Number of epochs to train for 200 Batch Number of images per batch 64 Imgsz Size of input images as integer or width, height 640 Optimizer Optimizer to use Adam Workers Number of worker threads used for data loading 8 4.2 Comparative experiments of different models The focus of this study is to improve detection speed and reduce model size without compromising detection accuracy. To validate the performance of the improved YOLOv8n with modified detection head in FDM 3D printing, we compared it with mainstream object detection algorithms including Faster R-CNN, YOLOv5n, YOLOv6n, YOLOv8n, and the improved YOLOv8n with modified detection head, all on the same dataset. The solution for the improved YOLOv8n with modified detection head involves using one GroupConv with shared weights. The comparison results are shown in Table 3 . Table 3 Different network test results Precision(P) Recall(R) mAP50 F1 FPS Parameters GFLOPs Faster R-CNN 0.867 0.983 0.979 0.92 2.29 41 251.4 YOLOv5n 0.923 0.864 0.928 0.89 77.8 2.5 7.2 YOLOv6n 0.927 0.853 0.933 0.89 71.3 4.23 11.9 YOLOv8n 0.925 0.921 0.968 0.92 78.4 3.0 8.2 Improved head 0.939 0.938 0.975 0.94 92.6 2.35 5.5 The detection speed metric FPS is an important indicator for evaluating model speed, while mAP50 measures the average precision of the model at a 50% IoU threshold. Average precision refers to calculating the precision of the model for each class at different IoU thresholds and averaging them. The 50% IoU is a common threshold, requiring the overlap area between the detection box and the ground truth box to be at least half of the ground truth box area. mAP50 is a significant metric for assessing the accuracy of object detection models. By constructing a mAP50-FPS plot, we can intuitively observe that the improved YOLOv8n with modified detection head maintains a good average precision while achieving a significant increase in detection speed FPS, as shown in Fig. 8 . In object detection, GFLOPs are a measure of the computational complexity of a model, representing the total number of floating-point operations performed during the inference process. GFLOPs can be used to assess the computational complexity of different object detection models. In general, models with fewer GFLOPs may be more attractive when computational resources are limited because they may be more suitable for deployment on edge devices or mobile devices. In this study, reducing the size of the model's GFLOPs is crucial for the subsequent deployment of the model on edge devices or mobile devices, as utilizing fewer computational resources is important for deploying the model on FDM 3D printing devices. We visualize the relationship between the computational power required during the detection process and the average precision of detection by plotting the GFLOPs-mAP50 graph, as shown in Fig. 9 . Finally, through comprehensive evaluation of various models based on Precision (P), Recall (R), Mean Average Precision (mAP), F1 score, Frames Per Second (FPS), Parameters, and GFLOPs, it can be observed that the improved detection head of YOLOv8n slightly outperforms other detection models in terms of Precision (P), Recall (R), Mean Average Precision (mAP), and F1 score. Meanwhile, our detection speed has been improved compared to other detection models, and the model's Parameters and GFLOPS have been significantly reduced. By leveraging the lightweight detection head in the improved YOLOv8 model, while maintaining detection accuracy, the overall model parameters are reduced, thereby reducing computational load and significantly improving detection speed. 4.3 Improved model verification To explore how lightweight detection heads can achieve optimal detection results, six different detection models based on the YOLOv8n detection head network structure were designed according to the selected improvement schemes. Model 1 represents the original YOLOv8n without any modifications, facilitating comparison with the original network model, while the remaining improvement schemes are shown in Table 4 . Table 4 Configuration of different improvement plans Model number Number of 3x3 Conv Number of 3x3 GroupConv Model 1(original model) 0 0 Model 2 2 0 Model 3 1 0 Model 4 2 0 Model 5(model we used) 1 0 Model 6 1 1 After training the models with the respective approaches, they were validated using the same evaluation criteria as before. The results are shown in Table 5 . Table 5 Validation results of different improvement approaches Precision(P) Recall(R) mAP50 F1 FPS Parameters GFLOPs Model 1 0.925 0.921 0.968 0.92 78.4 3.0 8.2 Model 2 0.928 0.868 0.961 0.90 80.5 3.8 8.2 Model 3 0.893 0.932 0.959 0.91 86.5 3.0 6.7 Model 4 0.912 0.906 0.964 0.91 80.2 2.4 5.8 Model 5 0.939 0.938 0.975 0.94 92.6 2.35 5.5 Model 6 0.927 0.883 0.946 0.90 82.7 3.1 6.9 By comparing the Precision, Recall, mAP50, F1 score, FPS, Parameters, and GFLOPs of each approach, we comprehensively evaluated the performance of the models. It can be observed that model 5 (1 GroupConv) outperforms other approaches in all aspects. The mAP50 of model 5 is 0.7% higher than that of the original YOLOv8n, indicating a slight improvement in detection accuracy compared to the original YOLOv8n. Additionally, the FPS and GFLOPs of model 5 have increased by 18.1% and decreased by 32.9%, respectively. This suggests that model 5 can achieve higher accuracy and detection speed with less computational resources compared to the original YOLOv8n, which is crucial for real-time detection and accuracy in FDM 3D printing. Additionally, this ensures that the model can be effectively deployed on platforms with lower computational power or embedded devices. 5. Real-time defect detection system 5.1 Detection system hardware conditions The hardware requirements of the detection system refer to the conditions of the acquisition device, as shown in Fig. 10 . This detection system consists of three parts: firstly, a 3D printer that performs 3D printing tasks, capable of executing G-Code to achieve 3D printing; secondly, an image acquisition device that utilizes an industrial camera in conjunction with a ring light source to obtain clear real-time printing images, which are then inputted into the computer; finally, a computer equipped with real-time detection software, which processes real-time images captured by the acquisition device using detection algorithms to achieve real-time detection of defects during the printing process. It is worth noting that both the 3D printer and the industrial camera are readily available devices on the market, demonstrating the versatility of this system; the computer configuration is identical to that of the hardware setup in Section 4.1, highlighting the system's ability to achieve real-time detection even under low computational power conditions. 5.2 Detection system software detection process The real-time detection system, developed using PyQt5 and open-source computer vision libraries, achieves functionalities such as online image acquisition, visualization of the detection process, browsing of detection results, and defect warning. Thanks to the powerful performance of the improved YOLOv8 model for the detection head, defect detection can be carried out with input images simply converted to grayscale before detection. This significantly reduces the image preprocessing process and minimizes the utilization of computational resources. The real-time detection process algorithm is illustrated in Fig. 11 . When the 3D printer initiates printing, the industrial camera begins capturing images. These images are collected in real-time, saved, and converted to grayscale. The improved YOLOv8 model of the detection head analyzes the grayscale images of the printed object to detect defects. If no defects are found, the grayscale images of the printed object are re-evaluated after a set interval. However, if defects are detected, the printing process is halted. The detection system, as shown in Fig. 12 , encompasses the following functionalities: Initialization: Searches and selects connected cameras, and toggles device power on or off. Collecting: Adjusts camera capture mode (continuous or trigger mode), starts or stops collecting, and saves captured image data. Parameters: Retrieves and sets camera parameters, including exposure, gain, and frame rate adjustments. Detection: Sets detection time intervals, initiates detection, and prints detection results. The software detection process proceeds as follows: Firstly, it acquires online camera devices and opens them to obtain images, defaulting to continuous capture mode. It adjusts camera exposure, gain, and frame rate parameters to ensure clear image capture. Detection intervals are set to periodically inspect printed object defects. Finally, the detected defect types are printed, and defect images are displayed in the bottom right corner of the interface. 5.3 Practical application results The application scenario demonstrates the real-time monitoring of defects during the printing process, accurately identifying defects across five different types, as shown in Fig. 13 . Specifically, (a), (b), (c), (d), and (e) correspond to curling, cracking, stringing, layer misalignment, and platform detachment defects, respectively. The detection system promptly and accurately identifies defects occurring during the printing process. By continuously monitoring and accurately identifying these defects in real-time, timely corrective measures can be taken to improve printing quality and efficiency, thereby reducing resource wastage. 6. Conclusion By comparing mainstream object detection algorithms for FDM 3D printing defect detection, we find that the current YOLOv8n detection algorithm achieves excellent detection accuracy. However, in practical production settings for FDM 3D printing, high computational power platforms are not always ideal. Therefore, a lightweight model with high detection accuracy and fast detection speed is essential for defect detection in FDM 3D printing. We have improved the YOLOv8n detection head to enhance detection speed and reduce model size while maintaining detection accuracy for real-time defect detection in FDM 3D printing. The improved detection head reduces convolutional volume by sharing weights and further enhances detection speed and reduces computational power by introducing group convolution. We evaluated the proposed method using a real FDM 3D printing defect dataset. Experimental results show that the method achieves high detection accuracy (mAP50 = 0.975) and detection speed (approximately 92.4 FPS), meeting the requirements of real-time defect detection. Additionally, our model has a parameter size of 2.35M, making it lighter than the original YOLOv8n model. We also designed a real-time detection system based on the improved YOLOv8n detection head model, which includes real-time image acquisition and real-time defect detection during printing. Although the method based on the improved YOLOv8n detection head provides a feasible solution for real-time defect detection, it still has certain limitations in dealing with various complex scenarios and defects in different material prints. Future research can focus on enhancing detection robustness and generalization ability through more diverse data augmentation and model optimization. With the development of IoT technology, intelligent manufacturing systems will become an essential part of future factories. In this context, integrating real-time defect detection with automated production lines to achieve a closed-loop system of defect detection and timely feedback repair will be a challenging yet highly promising direction. Therefore, future research can explore how to integrate lightweight detection models with intelligent manufacturing systems to achieve more efficient and intelligent production processes. Declarations Acknowledgment This research was supported by Key R&D projects in Zhejiang Province (No. 2024C01042). Competing Interests:The authors declare no competing interests. Data availability Data will be available from corresponding author upon reasonable request. References Inzana JA, Olvera D, Fuller SM, et al (2014) 3D printing of composite calcium phosphate and collagen scaffolds for bone regeneration. Biomaterials 35:4026–4034. https://doi.org/10.1016/j.biomaterials.2014.01.064 DebRoy T, Wei HL, Zuback JS, et al (2018) Additive manufacturing of metallic components – Process, structure and properties. Progress in Materials Science 92:112–224. https://doi.org/Associated Composite Wickramasinghe S, Do T, Tran P (2020) FDM-Based 3D Printing of Polymer and Associated Composite: A Review on Mechanical Properties, Defects and Treatments. Polymers 12:1529. https://doi.org/10.3390/polym12071529 Ligon SC, Liska R, Stampfl J, et al (2017) Polymers for 3D Printing and Customized Additive Manufacturing. Chem Rev 117:10212–10290. https://doi.org/10.1021/acs.chemrev.7b00074 Penumakala PK, Santo J, Thomas A (2020) A critical review on the fused deposition modeling of thermoplastic polymer composites. Composites Part B: Engineering 201:108336. https://doi.org/10.1016/j.compositesb.2020.108336 Ngo TD, Kashani A, Imbalzano G, et al (2018) Additive manufacturing (3D printing): A review of materials, methods, applications and challenges. Composites Part B: Engineering 143:172–196. https://doi.org/10.1016/j.compositesb.2018.02.012 Awasthi P, Banerjee SS (2021) Fused deposition modeling of thermoplastic elastomeric materials: Challenges and opportunities. Additive Manufacturing 46:102177. https://doi.org/10.1016/j.addma.2021.102177 Ferretti P, Leon-Cardenas C, Santi GM, et al (2021) Relationship between FDM 3D Printing Parameters Study: Parameter Optimization for Lower Defects. Polymers 13:2190. https://doi.org/10.3390/polym13132190 Baumann F, Roller D (2016) Vision based error detection for 3D printing processes. MATEC Web of Conferences 59:06003. https://doi.org/10.1051/matecconf/20165906003 Bhavsar P, Sharma B, Moscoso-Kingsley W, Madhavan V (2020) Detecting first layer bond quality during FDM 3D printing using a discrete wavelet energy approach. Procedia Manufacturing 48:718–724. https://doi.org/10.1016/j.promfg.2020.05.104 Lopes TG, Aguiar PR, Monson PMDC, et al (2023) Machine condition monitoring in FDM based on electret microphone, SVM, and neural networks. Int J Adv Manuf Technol 129:1769–1786. https://doi.org/10.1007/s00170-023-12375-0 Zhao X, Lian Q, He Z, Zhang S (2020) Region-based online flaw detection of 3D printing via fringe projection. Meas Sci Technol 31:035011. https://doi.org/10.1088/1361-6501/ab524b Li X-Y, Liu F-L, Zhang M-N, et al (2023) A Combination of Vision- and Sensor-Based Defect Classifications in Extrusion-Based Additive Manufacturing. Journal of Sensors 2023:1–13. https://doi.org/10.1155/2023/1441936 Yean FP, Chew WJ (2024) Detection of Spaghetti and Stringing Failure in 3D Printing. In: 2024 International Conference on Green Energy, Computing and Sustainable Technology (GECOST). IEEE, Miri Sarawak, Malaysia, pp 293–298 Shen H, Sun W, Fu J (2019) Multi-view online vision detection based on robot fused deposit modeling 3D printing technology. Rapid Prototyping Journal 25:343–355. https://doi.org/10.1108/RPJ-03-2018-0052 Zhao X, Li Q, Xiao M, He Z (2023) Defect detection of 3D printing surface based on geometric local domain features. Int J Adv Manuf Technol 125:183–194. https://doi.org/10.1007/s00170-022-10662-w Holzmond O, Li X (2017) In situ real time defect detection of 3D printed parts. Additive Manufacturing 17:135–142. https://doi.org/10.1016/j.addma.2017.08.003 Kumar S, Kolekar T, Patil S, et al (2022) A Low-Cost Multi-Sensor Data Acquisition System for Fault Detection in Fused Deposition Modelling. Sensors 22:517. https://doi.org/10.3390/s22020517 Rettenberger L, Beyer N, Sieber I, Reischl M (2024) Fault Detection in 3D-Printing with Deep Learning. In: 2024 IEEE International Conference on Consumer Electronics (ICCE). IEEE, Las Vegas, NV, USA, pp 1–4. https://doi.org/10.1109/ICCE59016.2024.10444198 Zhang H, Zong Z, Yao Y, et al (2023) Multi-Axis 3D Printing Defect Detecting by Machine Vision with Convolutional Neural Networks. Exp Tech 47:619–631. https://doi.org/10.1007/s40799-022-00577-2 Farhan Khan M, Alam A, Ateeb Siddiqui M, et al (2021) Real-time defect detection in 3D printing using machine learning. Materials Today: Proceedings 42:521–528. https://doi.org/10.1016/j.matpr.2020.10.482 Zhang Y, Zhang Z, Fu K, Luo X (2022) Adaptive Defect Detection for 3-D Printed Lattice Structures Based on Improved Faster R-CNN. IEEE Trans Instrum Meas 71:1–9. https://doi.org/10.1109/TIM.2022.3200362 Xu L, Zhang X, Ma F, et al (2023) Detecting defects in fused deposition modeling based on improved YOLO v4. Mater Res Express 10:095304. https://doi.org/10.1088/2053-1591/acf6f9 Paraskevoudis K, Karayannis P, Koumoulos EP (2020) Real-Time 3D Printing Remote Defect Detection (Stringing) with Computer Vision and Artificial Intelligence. Processes 8:1464. https://doi.org/10.3390/pr8111464 Kim H, Lee H, Ahn S-H (2022) Systematic deep transfer learning method based on a small image dataset for spaghetti-shape defect monitoring of fused deposition modeling. Journal of Manufacturing Systems 65:439–451. https://doi.org/10.1016/j.jmsy.2022.10.009 Kozhay K, Turarbek S, Asselbekova T, et al (2024) Convolutional Neural Network-Based Defect Detection Technique in FDM Technology. Procedia Computer Science 231:119–128. https://doi.org/10.1016/j.procs.2023.12.183 Günaydın, K., & Türkmen, H. S. (2018). Common FDM 3D printing defects. In International congress on 3D printing (additive manufacturing) technologies and digital industry. No. April 2018, pp. 19-21 Baechle-Clayton M, Loos E, Taheri M, Taheri H (2022) Failures and Flaws in Fused Deposition Modeling (FDM) Additively Manufactured Polymers and Composites. J Compos Sci 6:202. https://doi.org/10.3390/jcs6070202 Jocher, G., Chaurasia, A., Qiu, J.: YOLO by Ultralytics (2023) Krizhevsky A, Sutskever I, Hinton GE (2017) ImageNet classification with deep convolutional neural networks. Commun ACM 60:84–90. https://doi.org/10.1145/3065386 Supplementary Files Realtimedetectionsystemoperationvideo.mp4 Cite Share Download PDF Status: Published Journal Publication published 17 Sep, 2024 Read the published version in The International Journal of Advanced Manufacturing Technology → Version 1 posted Editorial decision: Minor Revisions Needed 27 Aug, 2024 Reviewers agreed at journal 16 May, 2024 Reviewers invited by journal 16 May, 2024 Editor assigned by journal 08 May, 2024 First submitted to journal 06 May, 2024 You are reading this latest preprint version Research Square lets you share your work early, gain feedback from the community, and start making changes to your manuscript prior to peer review in a journal. As a division of Research Square Company, we’re committed to making research communication faster, fairer, and more useful. We do this by developing innovative software and high quality services for the global research community. Our growing team is made up of researchers and industry professionals working together to solve the most critical problems facing scientific publishing. Also discoverable on Platform About Our Team In Review Editorial Policies Advisory Board Help Center Resources Author Services Accessibility API Access RSS feed Manage Cookie Preferences © Research Square 2026 | ISSN 2693-5015 (online) Privacy Policy Terms of Service Do Not Sell My Personal Information {"props":{"pageProps":{"initialData":{"identity":"rs-4380689","acceptedTermsAndConditions":true,"allowDirectSubmit":false,"archivedVersions":[],"articleType":"Research Article","associatedPublications":[],"authors":[{"id":303158484,"identity":"38ac415f-de6a-4f2c-ba0e-2a8708c32e8c","order_by":0,"name":"WenJing Hu","email":"","orcid":"","institution":"","correspondingAuthor":false,"prefix":"","firstName":"WenJing","middleName":"","lastName":"Hu","suffix":""},{"id":303158485,"identity":"742628a5-a156-4285-8adb-c3d0734b34d9","order_by":1,"name":"Chen Chang","email":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAAyAQMAAABI0h/eAAAABlBMVEX///8AAABVwtN+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA2UlEQVRIiWNgGAWjYDACCSBmbAAS7D0INpFaeM6QrEUih0gt/LObjz34ucMuTz7y7cHbPAw2shsOMD97gNeSO8fSDXvPJBcb3s5LtuZhSDPecIDN3ACfFgOJHDNpxjbmxI2zgQwehsOJGw7wsEng15L/DailPnHjzDMgLf+J0ZLDBtRyOHG+BA9IywHCWiRupJlJ9rYdT9zAk2NsOccg2XjmYTYzvFr4ZyQ/k/jZVp04v/2M4Y03FXayfcebn+HVgnDhATAJxMxEqQcC+QZiVY6CUTAKRsGIAwCOwkZlH+qrDgAAAABJRU5ErkJggg==","orcid":"","institution":"Hangzhou Dianzi University","correspondingAuthor":true,"prefix":"","firstName":"Chen","middleName":"","lastName":"Chang","suffix":""},{"id":303158486,"identity":"4de8a9af-3ae2-49b9-8bad-52830b072220","order_by":2,"name":"Shaohui Su","email":"","orcid":"","institution":"","correspondingAuthor":false,"prefix":"","firstName":"Shaohui","middleName":"","lastName":"Su","suffix":""},{"id":303158487,"identity":"a7612566-9712-42e2-8e01-c2319bd7683d","order_by":3,"name":"Jian Zhang","email":"","orcid":"","institution":"","correspondingAuthor":false,"prefix":"","firstName":"Jian","middleName":"","lastName":"Zhang","suffix":""},{"id":303158488,"identity":"bb8af443-518c-40c8-8244-79ec0be88984","order_by":4,"name":"An Zhu","email":"","orcid":"","institution":"","correspondingAuthor":false,"prefix":"","firstName":"An","middleName":"","lastName":"Zhu","suffix":""}],"badges":[],"createdAt":"2024-05-07 06:31:32","currentVersionCode":1,"declarations":"","doi":"10.21203/rs.3.rs-4380689/v1","doiUrl":"https://doi.org/10.21203/rs.3.rs-4380689/v1","draftVersion":[],"editorialEvents":[{"content":"https://doi.org/10.1007/s00170-024-14452-4","type":"published","date":"2024-09-17T15:58:02+00:00"}],"editorialNote":"","failedWorkflow":false,"files":[{"id":57079016,"identity":"53ea071e-3782-4272-82a1-fe0e6199e6b2","added_by":"auto","created_at":"2024-05-24 10:05:11","extension":"png","order_by":1,"title":"Figure 1","display":"","copyAsset":false,"role":"figure","size":4937642,"visible":true,"origin":"","legend":"\u003cp\u003eCommon printing defects\u003c/p\u003e\n\u003cp\u003e(a)Warping (b) Cracking (c) Stringing (d) Layer shifting (e) Off platform\u003c/p\u003e","description":"","filename":"Fig.1Commonprintingdefects.png","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/c035adae8b4c05e35d183410.png"},{"id":57079034,"identity":"3bee0835-fdfb-4e3b-864a-f25ca54d3df7","added_by":"auto","created_at":"2024-05-24 10:05:12","extension":"png","order_by":2,"title":"Figure 2","display":"","copyAsset":false,"role":"figure","size":3755471,"visible":true,"origin":"","legend":"\u003cp\u003eImage acquisition device\u003c/p\u003e","description":"","filename":"Fig.2Imageacquisitiondevice.png","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/97d65f744bf7fc4def8ac331.png"},{"id":57079019,"identity":"0e8b2220-acbc-4f34-bd1c-dc1d74ccbc28","added_by":"auto","created_at":"2024-05-24 10:05:11","extension":"png","order_by":3,"title":"Figure 3","display":"","copyAsset":false,"role":"figure","size":4320007,"visible":true,"origin":"","legend":"\u003cp\u003eImage enhancement results\u003c/p\u003e\n\u003cp\u003e(a) Original image (b) Grayscale (c) Elastic transformation\u003c/p\u003e\n\u003cp\u003e(d) Counterclockwise rotation 45° (e) Clockwise rotation 45°\u003c/p\u003e","description":"","filename":"Fig.3Imageenhancementresults.png","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/bd12607fe7d207c91ef5203b.png"},{"id":57079036,"identity":"9aac9084-bcec-4b86-b1af-e68c2afbf758","added_by":"auto","created_at":"2024-05-24 10:05:12","extension":"png","order_by":4,"title":"Figure 4","display":"","copyAsset":false,"role":"figure","size":1319456,"visible":true,"origin":"","legend":"\u003cp\u003eYOLOv8 detection head structure\u003c/p\u003e","description":"","filename":"Fig.4YOLOv8detectionheadstructure.png","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/d5d0b5c04e3539108bdf08cc.png"},{"id":57079021,"identity":"8e836b4e-b9e0-4df3-bfde-05a26a936751","added_by":"auto","created_at":"2024-05-24 10:05:11","extension":"png","order_by":5,"title":"Figure 5","display":"","copyAsset":false,"role":"figure","size":1258524,"visible":true,"origin":"","legend":"\u003cp\u003eDetection head structure diagram of shared parameters\u003c/p\u003e\n\u003cp\u003e(a) Two 3x3 Conv (b) One 3x3 Conv\u003c/p\u003e","description":"","filename":"Fig.5Detectionheadstructurediagramofsharedparameters.png","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/cffc1a244bac29ee37d052dd.png"},{"id":57079027,"identity":"11c59dd6-1351-4493-956a-45b1aa8ecf03","added_by":"auto","created_at":"2024-05-24 10:05:11","extension":"png","order_by":6,"title":"Figure 6","display":"","copyAsset":false,"role":"figure","size":1306948,"visible":true,"origin":"","legend":"\u003cp\u003eSchematic diagram of grouped convolution\u003c/p\u003e","description":"","filename":"Fig.6Schematicdiagramofgroupedconvolution.png","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/a07022c6e93ea7edad60f112.png"},{"id":57079785,"identity":"cd2ad5e6-6984-4f99-832f-d4dccfa24ddf","added_by":"auto","created_at":"2024-05-24 10:13:11","extension":"png","order_by":7,"title":"Figure 7","display":"","copyAsset":false,"role":"figure","size":1505811,"visible":true,"origin":"","legend":"\u003cp\u003eStructure of the detection head with shared parameters introduced by GroupConv.\u003c/p\u003e\n\u003cp\u003e(a) Two 3x3 GroupConv (b) One 3x3 GroupConv\u003c/p\u003e","description":"","filename":"Fig.7thedetectionheadintroducedbyGroupConv..png","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/f4b0c1c18d5bc41c5078e3fd.png"},{"id":57079040,"identity":"a2f488a0-6b75-4638-aab9-f375cab9a5d4","added_by":"auto","created_at":"2024-05-24 10:05:12","extension":"png","order_by":8,"title":"Figure 8","display":"","copyAsset":false,"role":"figure","size":641553,"visible":true,"origin":"","legend":"\u003cp\u003emAP50-FPS comparison chart (the performance is better toward the upper right corner)\u003c/p\u003e","description":"","filename":"Fig.8mAP50FPScomparisonchart.png","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/f75608e2351b2c3a37e7e788.png"},{"id":57079028,"identity":"44679e56-7f7d-4f2b-9b81-e03b55dbbc3b","added_by":"auto","created_at":"2024-05-24 10:05:12","extension":"png","order_by":9,"title":"Figure 9","display":"","copyAsset":false,"role":"figure","size":686331,"visible":true,"origin":"","legend":"\u003cp\u003emAP50-GFLOPs comparison chart (Performance improves towards the top left corner)\u003c/p\u003e","description":"","filename":"Fig.9mAP50GFLOPscomparisonchart.png","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/deb6e5ae43093b7e0f61323b.png"},{"id":57079786,"identity":"c0a170ce-4779-4f7e-9872-5c201c36bab9","added_by":"auto","created_at":"2024-05-24 10:13:11","extension":"png","order_by":10,"title":"Figure 10","display":"","copyAsset":false,"role":"figure","size":5692326,"visible":true,"origin":"","legend":"\u003cp\u003eHardware conditions of the detection system\u003c/p\u003e","description":"","filename":"Fig.10Hardwareconditionsofthedetectionsystem.png","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/f1b160ef6a601e84a551c325.png"},{"id":57079787,"identity":"591d5a37-50b2-4750-81e7-ca4911233419","added_by":"auto","created_at":"2024-05-24 10:13:12","extension":"png","order_by":11,"title":"Figure 11","display":"","copyAsset":false,"role":"figure","size":1048560,"visible":true,"origin":"","legend":"\u003cp\u003eReal-time detection system operation process\u003c/p\u003e","description":"","filename":"Fig.11Realtimedetectionsystemoperationprocess.png","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/37acb76c64bc84d878463a9c.png"},{"id":57079017,"identity":"a5ce582a-62bd-4a56-af11-434e94da29e2","added_by":"auto","created_at":"2024-05-24 10:05:11","extension":"png","order_by":12,"title":"Figure 12","display":"","copyAsset":false,"role":"figure","size":6055444,"visible":true,"origin":"","legend":"\u003cp\u003eReal-time monitoring graphical interface\u003c/p\u003e","description":"","filename":"Fig.12Realtimemonitoringgraphicalinterface.png","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/3431a3a6a511a61cf207c58a.png"},{"id":57079018,"identity":"82085a02-8cb9-47cd-b544-2f7c24b5b20a","added_by":"auto","created_at":"2024-05-24 10:05:11","extension":"png","order_by":13,"title":"Figure 13","display":"","copyAsset":false,"role":"figure","size":6971631,"visible":true,"origin":"","legend":"\u003cp\u003eTest result\u003c/p\u003e\n\u003cp\u003e(a)Warping (b) Cracking (c) Stringing (d) Layer shifting (e) Off platform\u003c/p\u003e","description":"","filename":"Fig.13Testresult.png","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/58e7a2d5ba946a03ee3cf67f.png"},{"id":65104989,"identity":"c874f674-a9c9-43a6-bc26-cb638ff5b40c","added_by":"auto","created_at":"2024-09-23 16:14:32","extension":"pdf","order_by":0,"title":"","display":"","copyAsset":false,"role":"manuscript-pdf","size":63271941,"visible":true,"origin":"","legend":"","description":"","filename":"manuscript.pdf","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/0c5f396b-12ee-4861-a4bf-75ff26ca2725.pdf"},{"id":57079043,"identity":"83db9738-3177-4f84-b2af-63cd95bfa01d","added_by":"auto","created_at":"2024-05-24 10:05:13","extension":"mp4","order_by":18,"title":"","display":"","copyAsset":false,"role":"supplement","size":64197816,"visible":true,"origin":"","legend":"","description":"","filename":"Realtimedetectionsystemoperationvideo.mp4","url":"https://assets-eu.researchsquare.com/files/rs-4380689/v1/7a7de2edd1f57d352889fcf4.mp4"}],"financialInterests":"","formattedTitle":"Real-time defect detection for FDM 3D printing using lightweight model deployment","fulltext":[{"header":"1. Introduction","content":"\u003cp\u003eIn recent years, 3D printing technology has become an important innovation in the manufacturing field and is widely used in industry, medicine and other fields [\u003cspan citationid=\"CR1\" class=\"CitationRef\"\u003e1\u003c/span\u003e][\u003cspan citationid=\"CR2\" class=\"CitationRef\"\u003e2\u003c/span\u003e]. Among these technologies, Fused Deposition Modeling (FDM) stands out due to its simplicity, speed, and cost-effectiveness, making it excel in areas such as rapid prototyping, personalized customization, and small-batch production [\u003cspan citationid=\"CR3\" class=\"CitationRef\"\u003e3\u003c/span\u003e][\u003cspan citationid=\"CR4\" class=\"CitationRef\"\u003e4\u003c/span\u003e]. However, during the printing process, operational faults caused by improper processing parameter settings and external disturbances, as well as health-related faults stemming from mechanical damage to the printer, often lead to destructive defects in printed parts [\u003cspan additionalcitationids=\"CR6\" citationid=\"CR5\" class=\"CitationRef\"\u003e5\u003c/span\u003e\u0026ndash;\u003cspan citationid=\"CR7\" class=\"CitationRef\"\u003e7\u003c/span\u003e]. With the continuous expansion of its applications, quality control and defect detection in FDM 3D printing have become one of the key issues that urgently need to be addressed [\u003cspan citationid=\"CR8\" class=\"CitationRef\"\u003e8\u003c/span\u003e]. Currently, most detection methods involve quality checks after printing completion, which cannot detect and identify issues in real time during the printing process. Such detection methods undoubtedly result in the wastage of time and materials.\u003c/p\u003e \u003cp\u003eResearchers have conducted numerous studies to address the defects occurring during the printing process, aiming to rectify issues leading to product non-conformities. In detection, non-destructive testing is a widely employed method in FDM 3D printing, where error detection mechanisms using cameras provide feasibility for remote supervision and early fault detection [\u003cspan citationid=\"CR9\" class=\"CitationRef\"\u003e9\u003c/span\u003e]. Bhavsar et al. [\u003cspan citationid=\"CR10\" class=\"CitationRef\"\u003e10\u003c/span\u003e] utilized discrete wavelet transform to analyze the differences in vibration acoustic signals of sensors during FDM 3D printing, aiming to detect the first layer filament deposition process, thereby achieving detection of first layer bonding quality. Machine learning finds extensive application in defect detection, as demonstrated by Lopes et al. [\u003cspan citationid=\"CR11\" class=\"CitationRef\"\u003e11\u003c/span\u003e], who employed piezoelectric microphones, support vector machines (SVMs), and neural networks for machine state monitoring in FDM 3D printing. Through signal processing and feature extraction techniques such as RMS values and spectral analysis, the study identified raw signal patterns associated with different machine conditions (such as normal operation, extruder blockages, and filament shortages). Classification using machine learning algorithms like SVMs and neural networks, alongside signal filtering, can enhance model accuracy. Zhao et al. [\u003cspan citationid=\"CR12\" class=\"CitationRef\"\u003e12\u003c/span\u003e] proposed a novel online inspection technique using stripe projection for 3D printing, aiming to enhance the stability and quality of additive manufacturing processes. The proposed method involves region-based defect detection, improving detection accuracy by analyzing sub-regions. By combining Voxel Cloud Connectivity Segmentation (VCCS) and Fast Point Feature Histograms (FPFH), the printing area is divided into multiple sub-regions for evaluation.\u003c/p\u003e \u003cp\u003eWith the advancement of visual technology, defect detection methods are not limited to analyzing vibration signals on sensors alone. Li et al. [\u003cspan citationid=\"CR13\" class=\"CitationRef\"\u003e13\u003c/span\u003e], for instance, combined visual and sensor-based defect classification methods, monitoring sensor signals (temperature and vibration data) and interlayer images during the printing process, establishing two machine learning models, and merging their predictive results to enhance defect classification accuracy. Yean et al. [\u003cspan citationid=\"CR14\" class=\"CitationRef\"\u003e14\u003c/span\u003e] combined AlexNet convolutional neural networks with support vector machine (SVM) classifiers for detecting spaghetti and stringing defects, achieving desirable accuracy in defect classification. Shen et al. [\u003cspan citationid=\"CR15\" class=\"CitationRef\"\u003e15\u003c/span\u003e], in the printing process of a six-degree-of-freedom robotic FDM printer, altered the detection field of view using surface vectors, effectively identifying defects based on layer compression structures and introduced mathematical matrix representation of defects for detecting printing defects based on geometric shapes and area distributions.\u003c/p\u003e \u003cp\u003eWith the advancement of 3D technology, the detection of FDM 3D printing defects has become more comprehensive. Utilizing 3D point cloud for defect detection provides detailed spatial information, enhancing defect identification. Zhao et al. [\u003cspan citationid=\"CR16\" class=\"CitationRef\"\u003e16\u003c/span\u003e] extracted potential defect areas using MBH and INRoPS feature descriptors, along with precise defect detection based on neighborhood point calculations, addressing the limitations of existing defect detection methods by providing more accurate and reliable results. Holzmond et al. [\u003cspan citationid=\"CR17\" class=\"CitationRef\"\u003e17\u003c/span\u003e] employed 3D Digital Image Correlation (3D-DIC) to transform image technology into three-dimensional data, comparing printed geometries with computer models for in-situ error detection, demonstrating the effectiveness of 3D-DIC systems in detecting local and global defects in test cases using Fused Filament Fabrication (FFF) 3D printers. Non-destructive testing using devices such as cameras enables remote supervision and early fault detection, facilitating early problem detection and resolution without destructive operations. Machine learning algorithms such as Support Vector Machines (SVMs) and neural networks effectively classify and recognize signals, enhancing detection accuracy and efficiency. Technologies like 3D point clouds provide detailed spatial information, enabling more accurate defect detection and description. However, some methods involve complex equipment and technologies, requiring specialized knowledge and skills for operation and maintenance, thus increasing implementation complexity. Some methods rely on specific equipment or environments, which may limit their applicability to practical scenarios, reducing their generality.\u003c/p\u003e \u003cp\u003eWith the rapid development of neural networks, they have found excellent applications in detecting defects in FDM 3D printing. A multi-sensor data acquisition system is employed to collect real-time signals such as vibration, current, and sound sensors during FDM 3D printing. These captured data are then analyzed in the time domain and frequency domain to create feature vectors for training CNN models, which are subsequently used for defect detection [\u003cspan citationid=\"CR18\" class=\"CitationRef\"\u003e18\u003c/span\u003e]. In addition to vibration signals, image signal acquisition is more convenient, faster, and cost-effective. A diverse set of image data, including various error levels and printing geometries, is required for training CNNs to ensure the system's generalization and effectiveness [\u003cspan citationid=\"CR19\" class=\"CitationRef\"\u003e19\u003c/span\u003e]. To make the detection process real-time, Zhang et al. [\u003cspan citationid=\"CR20\" class=\"CitationRef\"\u003e20\u003c/span\u003e] proposed a method using machine vision and convolutional neural networks (CNNs) to detect multi-axis FDM printing defects. Their self-built CNN network achieved an 83.1% classification accuracy for interlayer delamination defects. Farhan et al. [\u003cspan citationid=\"CR21\" class=\"CitationRef\"\u003e21\u003c/span\u003e] developed a CNN-deep learning model to detect real-time defects in 3D printing, such as inconsistent extrusion, weak infill, lack of support, or sagging. Using image detection methods, neural network models have demonstrated simplicity in data collection and the ability to detect defects in printing in real time.\u003c/p\u003e \u003cp\u003eDeep learning methods are currently widely applied and demonstrate excellent performance in classification, object detection, and segmentation tasks. In FDM 3D printing defect detection, object detection methods are highly favored because they can identify defect types and locations. Zhang et al. [\u003cspan citationid=\"CR22\" class=\"CitationRef\"\u003e22\u003c/span\u003e] improved Faster R-CNN using an adaptive defect detection method based on the K-medoids clustering algorithm to detect lattice structures in CT slices of 3D printing. Xu et al. [\u003cspan citationid=\"CR23\" class=\"CitationRef\"\u003e23\u003c/span\u003e] replaced the backbone structure of YOLO v4 with MobileNetV2 as an improved model to recognize defects in FDM 3D printing. Paraskevoudis et al. [\u003cspan citationid=\"CR24\" class=\"CitationRef\"\u003e24\u003c/span\u003e] used an SSD model to analyze video clips to identify defects during the printing process, especially stringing defects. Kim et al. [\u003cspan citationid=\"CR25\" class=\"CitationRef\"\u003e25\u003c/span\u003e] discussed a system depth transfer learning method based on a small image dataset for monitoring spaghetti defects in Fused Deposition Modeling (FDM) printers. Image signal acquisition is more convenient and faster, and through image processing techniques, status and defect information during the printing process can be intuitively obtained. In FDM 3D printing defect detection, deep learning methods, due to their deeper network structures, achieve higher detection accuracy compared to CNN methods, and exhibit stronger generalization capabilities. Therefore, the application of deep learning methods in FDM 3D printing defect detection is highly significant.\u003c/p\u003e \u003cp\u003eCurrently, research primarily involves collecting images of each layer of the print head during printing to determine if defects exist, or analyzing print images collected from above the printed part. However, this method has some drawbacks. Firstly, collecting detailed images of each layer, as done by Shen et al. [\u003cspan citationid=\"CR15\" class=\"CitationRef\"\u003e15\u003c/span\u003e], involves enhancing the image contrast using histogram equalization techniques, converting the original image to a binary image through local binary patterns, and finally applying median filtering to preserve sharp signal changes and eliminate pulse noise. After these cumbersome operations, a mathematical matrix composed of central coordinates, aspect ratio, and area distribution is introduced to represent defects. Secondly, as Kaisar et al. [\u003cspan citationid=\"CR26\" class=\"CitationRef\"\u003e26\u003c/span\u003e] demonstrated using images captured by a camera above the printed part, there remains an issue of only being able to detect misalignment and over-extrusion, rather than comprehensively detecting major defects during the printing process.\u003c/p\u003e \u003cp\u003eThe proposed approach in this paper suggests capturing images directly in front of the printed part, which offers significant advantages. Firstly, it reduces the difficulty of image collection, as it doesn't require special or complex equipment installation positions\u0026mdash;only clear images need to be captured. Secondly, capturing defect images from the front can encompass the most common defects, making it more versatile.\u003c/p\u003e \u003cp\u003eIn FDM 3D printing, defects can be categorized into single-layer defects and overall defects [\u003cspan citationid=\"CR27\" class=\"CitationRef\"\u003e27\u003c/span\u003e][\u003cspan citationid=\"CR28\" class=\"CitationRef\"\u003e28\u003c/span\u003e]. Single-layer defects include warping, stringing, bubbling, collapsing, wrinkling, interlayer delamination, and missing filament. Overall defects encompass sagging, warping, interlayer cracking, collapsing, overheating deformation, and layer misalignment. This paper aims to research and implement a defect detection system for FDM 3D printing based on an improved detection head using YOLOv8 for object detection. The objective is to comprehend real-time printing data during the printing process and promptly address any printing issues. By detecting common printing defects, the system ensures the quality of printed parts while reducing the waste of printing time and materials. We analyzed the formation mechanisms of common defects in the FDM 3D printing process, including warping, platform detachment, layer misalignment, interlayer delamination, and stringing. We used artificially generated defect images as the training dataset and improved the detection head of YOLOv8 to enhance detection performance, achieving automatic detection and classification of surface defects in printed parts. By comparing five improved detection heads, we sought the optimal improvement scheme and demonstrated the superiority of our improvement approach over conventional target detection methods by comparing the improved model with other mainstream target detection models. Additionally, we will establish a comprehensive experimental platform to validate the effectiveness and feasibility of the proposed method and explore its application prospects in practical production.\u003c/p\u003e \u003cp\u003eThe research findings of this paper will not only provide technical support for improving the quality and production efficiency of FDM 3D printing but also serve as a reference for defect detection issues in other similar application scenarios. It holds both theoretical and practical value.\u003c/p\u003e"},{"header":"2. Production of data sets","content":"\u003cdiv id=\"Sec3\" class=\"Section2\"\u003e\n \u003ch2\u003e2.1 Defect types and causes\u003c/h2\u003e\n \u003cp\u003eFDM printers can encounter various defects during the printing process due to printing environment and parameter settings. Among the most common defects are warping, cracking, stringing, layer shifting, and off-platform (Fig. \u003cspan class=\"InternalRef\"\u003e1\u003c/span\u003e).\u003c/p\u003e\n \u003cp\u003eWarping: This refers to the upward bending of the bottom edge of the printed object during printing, until it is no longer level with the print bed. This can lead to horizontal cracks at the top and even cause the printed object to detach from the print bed. Warping issues are primarily due to the natural characteristics of plastic materials. When materials like ABS or PLA cool down, they undergo slight shrinkage, and if the cooling process occurs too rapidly, warping issues can arise.\u003c/p\u003e\n \u003cp\u003eCracking: This refers to the poor connection between the layers of a part, causing them to separate. This issue may arise from two different reasons: Firstly, poor adhesion between layers, where layers fail to properly stick together. Poor adhesion is often caused by low printing temperatures, which can be addressed by increasing the printing temperature or reducing the layer fan speed. Secondly, thermal contraction occurs when the layers adhere well to each other, but temperature differences between different parts of the part result in deformation, leading to the separation of certain layers. Finally, abnormal up and down movements of the print platform during printing can result in significant gaps appearing in a particular layer of the printed part.\u003c/p\u003e\n \u003cp\u003eStringing: This refers to the residual filament-like objects left behind by the extruder when it moves across open spaces. The main reasons for stringing are as follows:\u003c/p\u003eInsufficient retraction distance: One of the most critical settings for retraction is the retraction distance, which determines how much filament is pulled back from the nozzle during retraction. Typically, the more filament is retracted from the nozzle, the less noticeable the stringing.\u003cspan\u003eRetraction speed too slow: Another important setting for retraction is the retraction speed, which determines how quickly the filament is pulled away.\u003cbr\u003e\u003c/span\u003e \u003cspan\u003eTemperature too high: If the temperature of the extruder is too high, the filament inside the nozzle becomes very viscous and tends to flow out of the nozzle easily. However, if the temperature is too low, it can be difficult for the filament to be extruded.\u003cbr\u003e\u003c/span\u003e \u003cspan\u003eExcessive travel distance without printing: The travel distance also has a significant impact on stringing. Short travel distances may not provide enough time for the melted filament to flow out of the nozzle, while long travel distances are more likely to cause stringing.\u003cbr\u003e\u003c/span\u003eLayer shifting: This refers to the occurrence of a layer being offset during the printing process. Most printers use stepper motors to drive machine movement, meaning the printer cannot detect the position of the print head. However, external forces or significant resistance can cause misalignment of the print head, and the printer lacks detection and correction measures, resulting in misalignment or displacement of the printed product. The reasons for layer misalignment are as follows:Excssive movement speed of the print head: If the print speed or travel speed exceeds the speed that the stepper motor can handle, misalignment issues may occur.\u003cp\u003eMechanical issues: Most machines utilize belt-driven mechanisms, and over time, the belts may elongate and become looser, leading to prolonged slipping off the pulley. \u003cspan\u003eElectronic issues: Insufficient power supply current to the stepper motor can result in inadequate force to overcome resistance.\u003cbr\u003e\u003c/span\u003e \u003cspan\u003eExternal forces: External forces pulling or tugging can cause displacement or misalignment, such as improper placement of consumables or extruder power lines, leading to pulling or entangling with other objects, resulting in layer shifting.\u003cbr\u003e\u003c/span\u003e\u003c/p\u003e\u003cbr\u003e\n \u003cp\u003eOff-platform: This refers to the scenario where the printed object fails to adhere firmly to the heated bed during the printing process, resulting in chaotic filament patterns. This often occurs when the first layer of material fails to adhere properly to the heated bed. The reasons for this may include the nozzle being too far from the bed, preventing proper adhesion of the filament to the bed; printing speed being too fast, causing the filament to fail to adhere to the bed promptly; or the bed temperature being too low, causing the extruded filament to shrink upon cooling, leading to poor adhesion.\u003c/p\u003e\n \u003cp\u003eThe reasons for the occurrence of printing defects during the printing process also serve as the foundation for creating the printing dataset. The dataset creation in this study involved deliberately designing incorrect printing parameters and printing environments. By adjusting the temperature difference between the print head and the print bed, the occurrence of warping and platform detachment can be controlled: in this study, warping could occur when the print head was set to 220\u0026deg;C and the print bed to 30\u0026deg;C. Off-platform could occur when the print head was set to 220\u0026deg;C and the print bed was at room temperature. Pausing the print and moving the print bed during printing could result in layer shifting. Pausing the print and adjusting the print bed height during printing could result in cracking. Disabling retraction or adjusting the retraction distance to 1mm in the printing software could result in stringing.\u003c/p\u003e\n \u003cp\u003eBy comparing artificially induced printing defects with spontaneously occurring ones, it is observed that artificially induced printing defects are essentially consistent with spontaneously occurring ones since they are designed experiments based on the causes of printing defects. Artificially induced printing defects help address the scarcity of defect data caused by the limited occurrence and randomness of defects, thus significantly alleviating the difficulty in creating the dataset.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"Sec4\" class=\"Section2\"\u003e\n \u003ch2\u003e2.2 Image data collection\u003c/h2\u003e\n \u003cp\u003eThe real-time 3D printing process image acquisition device designed in this study is shown in Fig. \u003cspan class=\"InternalRef\"\u003e2\u003c/span\u003e.\u003c/p\u003e\u003cbr\u003e\n \u003cp\u003e(a) is PLA printing material. PLA material exhibits good thermal stability and solvent resistance, with processing temperatures ranging from 170 to 230\u0026deg;C, and the final product has good heat resistance.\u003c/p\u003e\n \u003cp\u003e(b) is the Creality Ender 3 FDM 3D printer, with a maximum print size of 220220250mm, a maximum print speed of 180mm/s, a print accuracy of \u0026plusmn;\u0026thinsp;0.1mm, a nozzle diameter of 0.4mm, and a layer thickness of 0.1-0.35mm. \u003cspan\u003e(c) is a ring light source used to provide supplementary lighting for industrial cameras. In this paper, we preferred an adjustable brightness and color temperature LED ring light source to obtain 3D printed part images with uniform brightness and no shadows.\u003cbr\u003e\u003c/span\u003e \u003cspan\u003e(d) is the 1/1.8\u0026quot; 30mm 6MP FA lens from Hikvision, with model number MVL-HF3028M-6MPE.\u003cbr\u003e\u003c/span\u003e \u003cspan\u003e(e) is a 6-megapixel industrial line scan camera from Hikvision Robotics, model MV-CS060-10GC. The camera transmits images via a Gigabit Ethernet interface, enabling fast real-time data transfer with a frame rate of up to 19.1 fps at full resolution. It is used for real-time image acquisition of the 3D printing process with a real-time image acquisition device.\u003cbr\u003e\u003c/span\u003e\u003c/p\u003e2.3 Data set construction and analysis\u003cp\u003eData was collected using a data acquisition device, resulting in a total of 294 images. Among them, there were 50 images of layer shifting, 54 images of cracking, 58 images of stringing, 72 images of warping, and 60 images of off-platform, totaling 294 images. The image size in the dataset is 3072\u0026times;2048. Since the color of the images has minimal impact on defect detection, all images were converted to grayscale to reduce computational complexity.\u003c/p\u003e\n \u003cp\u003eThe performance of deep learning algorithms typically depends on having a sufficient number of training samples to provide an adequate representation of 3D printing defect features. With the limited samples available in the 3D printing defect dataset, overfitting during the training process can occur, making it difficult to detect new 3D printing defects effectively. Creating a comprehensive defect dataset requires a considerable amount of effort. However, utilizing common data augmentation techniques can achieve similar results. In this study, image enhancement methods were employed to improve the generalization ability of the deep learning model. The enhanced results, as shown in Fig. \u003cspan class=\"InternalRef\"\u003e3\u003c/span\u003e, yielded a total of 1176 augmented images.\u003c/p\u003e\n \u003cp\u003eImage Rotation: Image rotation augmentation is employed to enhance the dataset. This involves rotating the original image around the center of the image to generate new images.\u003c/p\u003e\n \u003cp\u003eElastic Transformation: Random standard deviations within the (-1, 1) interval are applied to each dimension of the pixel points. Gaussian filtering with a (0, sigma) filter is then performed on the deviation matrices for each dimension. Finally, the deviation range is controlled using the magnification coefficient alpha.\u003c/p\u003e\n \u003cp\u003e\u003cbr\u003e\u003c/p\u003eThis paper follows the widely accepted practice of dataset partitioning using an 8:1:1 ratio. This ensures the consistency and comparability of the evaluation method, contributing to the robustness and reliability of the results. By randomly dividing the dataset into three groups with an 8:1:1 ratio, we obtained 940 images in the training set, 118 images in the test set, and 118 images in the validation set, ensuring balanced distribution. This method avoids bias and overfitting while providing representative data distributions for training, validation, and testing.\u003cp\u003e\u003c/p\u003e\n\u003c/div\u003e"},{"header":"3. Improvement of detection algorithm","content":"\u003cdiv id=\"Sec7\"\u003e\n \u003ch2\u003e3.1 YOLOv8 network structure\u003c/h2\u003e\n \u003cp\u003eYOLOv8 [\u003cspan\u003e22\u003c/span\u003e], released as a significant update to YOLOv5 by Ultralytics in 2023, introduces new features and improvements to enhance performance and flexibility based on the historical versions of the YOLO series. It offers models at different scales (N/S/M/L/X) based on scaling coefficients to meet various scene requirements. The backbone network and Neck part may draw inspiration from the YOLOv7 ELAN design philosophy, replacing the C3 structure of YOLOv5 with a more gradient-flow-rich C2f structure. There are significant changes in the Head part compared to YOLOv5, where it adopts the mainstream decoupled head structure, separating classification and detection heads, and transitioning from Anchor-Based to Anchor-Free. Loss computation employs the task aligned assigner positive sample allocation strategy and introduces distribution focal loss.\u003c/p\u003e\n \u003cp\u003eThe YOLOv8 model comprises five different versions: YOLOv8n, YOLOv8s, YOLOv8m, YOLOv8l, and YOLOv8x, with increasing model sizes among these versions. Considering the balance between real-time monitoring speed and subsequent model embedding in embedded devices, we opt for YOLOv8n as the baseline model for this study.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"Sec8\"\u003e\n \u003ch2\u003e3.2 Improvement methods for detection head\u003c/h2\u003e\n \u003cp\u003eIn the YOLO series of algorithms, the detection head is a crucial component responsible for outputting information about the location and category of targets. It typically utilizes bounding boxes to represent the position of targets, which include coordinates such as the top-left and bottom-right corners, along with associated size information. Moreover, it outputs a vector of class scores, with each score indicating the confidence level for the corresponding category. Usually, the length of this vector is equal to the number of categories in the dataset, allowing the model to perform classification for each category. In YOLO, the detection head is typically connected to different levels of the convolutional neural network to extract information from different feature maps. This helps the model consider various scales and semantic information of the image simultaneously, thereby improving detection performance. The detection head plays a critical role in the YOLO algorithm, as it is responsible for predicting the location and category information of targets from input images, enabling the model to efficiently and accurately perform object detection tasks in a single forward pass.\u003c/p\u003e\n \u003cp\u003eYOLOv8 introduces a decoupled head structure, separating the classification and detection heads, which is currently a mainstream approach. However, this change also increases the computational complexity of the head section, as illustrated in Fig. \u003cspan\u003e5\u003c/span\u003e. Compared to the detection head of YOLOv5, the detection head of YOLOv8 has approximately 60 times more parameters, accounting for nearly 1/5 of the total computational load of YOLOv8. The computational load of the detection head directly affects the detection speed of the model. Moreover, reducing the computational requirements of the lightweight model can significantly enhance the portability of the entire detection system. Therefore, improving the detection head in the head section to maintain detection accuracy while significantly enhancing detection speed and lightweight model is a problem addressed in this study.\u003c/p\u003e\n \u003cp\u003eAs shown in Fig. \u003cspan\u003e4\u003c/span\u003e, the detection head of YOLOv8 consists of two branches, each utilizing two 3x3 convolutions (Conv) and one 1x1 convolution (Conv2d) to extract information, and finally calculate the bounding box loss and classification loss separately. However, YOLOv8 has three identical detection heads, which is the reason for the high computational demand for the detection head in YOLOv8. In light of this, as illustrated in Fig. \u003cspan\u003e5\u003c/span\u003e(a), the parameters of the first two 3x3 convolutions (Conv) can be shared, reducing the number of 3x3 convolutions (Conv) in the entire detection head from 4 to 2, resulting in a significant reduction in the parameter count. Alternatively, as shown in Fig. \u003cspan\u003e5\u003c/span\u003e(b), the two shared 3x3 convolutions (Conv) can be replaced with just one. This way, the number of 3x3 convolutions (Conv) in the detection head of the entire YOLOv8 model is reduced from 12 to 3, leading to a substantial decrease in the computational demand of the detection head.\u003c/p\u003e\n \u003cp\u003eGroup Convolution is a highly effective method for reducing the computational cost of convolutional operations, initially introduced in AlexNet. It introduces the concept of groups in convolution operations, allowing for more flexible handling of inputs and parameters. Typically, convolution operations process all channels of the input tensor and all filters simultaneously. In contrast, group convolution divides the channels of the input tensor into multiple groups, with each group sharing parameters. This reduces the number of parameters and computational costs significantly.\u003c/p\u003e\n \u003cp\u003eAs shown in Fig. \u003cspan\u003e6\u003c/span\u003e, the left side represents non-grouped convolution. In traditional convolutional operations, each convolutional kernel convolves with all channels of the input tensor, sharing the same set of parameters. Therefore, the total number of parameters required is:\u003c/p\u003e\n \u003cdiv id=\"Equa\"\u003e\n \u003cdiv id=\"FileID_Equa\" name=\"EquationSource\"\u003e$$\\begin{array}{c}n={k}^{2}{c}_{1}{c}_{2}\\#\\left(1\\right)\\end{array}$$\u003c/div\u003e\n \u003c/div\u003e\n \u003cp\u003eOn the right side, grouped convolution is employed, where the channels of the input tensor are evenly divided into \u003cem\u003eg\u003c/em\u003e groups, with each group containing \u003cem\u003ec/g\u003c/em\u003e channels. Then, each group\u0026apos;s channels are convolved with a portion of the convolutional kernels, where channels sharing the same convolutional kernel belong to the same group. Therefore, the total number of parameters required is:\u003c/p\u003e\n \u003cdiv id=\"Equb\"\u003e\n \u003cdiv id=\"FileID_Equb\" name=\"EquationSource\"\u003e$$\\begin{array}{c}n=\\frac{{k}^{2}{c}_{1}{c}_{2}}{g}\\#\\left(2\\right)\\end{array}$$\u003c/div\u003e\n \u003c/div\u003e\n \u003cp\u003eWe introduce GroupConv(Group Convolution) into the detection head of YOLOv8. Due to parameter sharing within each group, this helps to reduce model complexity and computational costs, as depicted in Fig. \u003cspan\u003e7\u003c/span\u003e. Additionally, as GroupConv divides the input tensor channels into multiple groups, the convolutional operations within each group can be performed in parallel, thereby improving network parallelism to some extent, which accelerates both training and detection speeds. Similarly, both convolutions can be replaced entirely with GroupConv, or only one GroupConv can be retained.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"Sec9\"\u003e\n \u003ch2\u003e3.3 Evaluation standards\u003c/h2\u003e\n \u003cp\u003eIn this study, Precision (P), Recall (R), Mean Average Precision (mAP), and F1 score are utilized to accurately evaluate the detection performance of the model. Precision (P) represents the proportion of correctly predicted positive samples to all samples predicted as positive. The calculation formula is as follows:\u003c/p\u003e\n \u003cdiv id=\"Equc\"\u003e\n \u003cdiv id=\"FileID_Equc\" name=\"EquationSource\"\u003e$$\\begin{array}{c}Precision=\\frac{TP}{TP+FP}\\times 100\\%\\#\\left(3\\right)\\end{array}$$\u003c/div\u003e\n \u003c/div\u003e\n \u003cp\u003eRecall (R) represents the proportion of correctly predicted positive samples to all actual positive samples. The calculation formula is:\u003c/p\u003e\n \u003cdiv id=\"Equd\"\u003e\n \u003cdiv id=\"FileID_Equd\" name=\"EquationSource\"\u003e$$\\begin{array}{c}Recall=\\frac{TP}{TP+FN}\\times 100\\%\\#\\left(4\\right)\\end{array}$$\u003c/div\u003e\n \u003c/div\u003e\n \u003cp\u003eWhere TP represents True Positives, FP represents False Positives, and FN represents False Negatives.\u003c/p\u003e\n \u003cp\u003eF1 score is a measure that combines precision and recall, it is the harmonic mean of precision and recall. The calculation formula is:\u003c/p\u003e\n \u003cdiv id=\"Eque\"\u003e\n \u003cdiv id=\"FileID_Eque\" name=\"EquationSource\"\u003e$$\\begin{array}{c}F1=\\frac{2\\times Precision\\times Recall}{Precision+Recall}\\times 100\\%\\#\\left(5\\right)\\end{array}$$\u003c/div\u003e\n \u003c/div\u003e\n \u003cp\u003eIn object detection, AP typically refers to the area under the Precision-Recall curve, providing a single value that encapsulates both precision and recall performance for evaluating the model comprehensively. In multi-class object detection tasks, mAP represents the average of AP values across all classes. The calculation formula is:\u003c/p\u003e\n \u003cdiv id=\"Equf\"\u003e\n \u003cdiv id=\"FileID_Equf\" name=\"EquationSource\"\u003e$$\\begin{array}{c}AP={\\int }_{0}^{1}PR dR\\times 100\\%\\#(6)\\end{array}$$\u003c/div\u003e\n \u003c/div\u003e\n \u003cdiv id=\"Equg\"\u003e\n \u003cdiv id=\"FileID_Equg\" name=\"EquationSource\"\u003e$$\\begin{array}{c}mAP=\\frac{1}{C}\\sum _{i=1}^{C}A{P}_{i}\\#(7)\\end{array}$$\u003c/div\u003e\n \u003c/div\u003e\n \u003cp\u003eIn this study, detection speed and model size are also two important metrics. We use Frames Per Second (FPS) to evaluate detection speed, Parameters to evaluate model size, and Floating Point Operations (FLOPs) to measure model complexity (1GFLOPs\u0026thinsp;=\u0026thinsp;1\u0026nbsp;billion floating point operations). Detection speed is related to the time for preprocessing, inference, and post-processing of images. The FPS represents the number of frames the model can process per second. A higher FPS means the model can process inputs faster. The calculation method for convolutional layer FLOPs is:\u003c/p\u003e\n \u003cdiv id=\"Equh\"\u003e\n \u003cdiv id=\"FileID_Equh\" name=\"EquationSource\"\u003e$$\\begin{array}{c}FLOPs=2\\times {kerne{l}_{size}}^{2}\\times inpu{t}_{channels}\\times outpu{t}_{channels}\\times outpu{t}_{size}\\#(8)\\end{array}$$\u003c/div\u003e\n \u003c/div\u003e\n\u003c/div\u003e"},{"header":"4. Experimental results and analysis","content":"\u003cdiv id=\"Sec11\" class=\"Section2\"\u003e \u003ch2\u003e4.1 Experimental platform and parameter settings\u003c/h2\u003e \u003cp\u003eTo achieve faster training and better training results, as well as to approximate the performance on low-computational platforms when deployed in practice, this study utilized different hardware platforms for training and testing, as shown in Table\u0026nbsp;\u003cspan refid=\"Tab1\" class=\"InternalRef\"\u003e1\u003c/span\u003e. The training parameters for this experiment are outlined in Table\u0026nbsp;\u003cspan refid=\"Tab2\" class=\"InternalRef\"\u003e2\u003c/span\u003e.\u003c/p\u003e \u003cp\u003e \u003cdiv class=\"gridtable\"\u003e\u003ctable float=\"Yes\" id=\"Tab1\" border=\"1\"\u003e \u003ccaption language=\"En\"\u003e \u003cdiv class=\"CaptionNumber\"\u003eTable 1\u003c/div\u003e \u003cdiv class=\"CaptionContent\"\u003e \u003cp\u003eTraining and testing platform conditions\u003c/p\u003e \u003c/div\u003e \u003c/caption\u003e \u003ccolgroup cols=\"3\"\u003e \u003cdiv align=\"left\" class=\"colspec\" colname=\"c1\" colnum=\"1\"\u003e\u003c/div\u003e \u003cdiv align=\"left\" class=\"colspec\" colname=\"c2\" colnum=\"2\"\u003e\u003c/div\u003e \u003cdiv align=\"left\" class=\"colspec\" colname=\"c3\" colnum=\"3\"\u003e\u003c/div\u003e \u003cthead\u003e \u003ctr\u003e \u003cth align=\"left\" colname=\"c1\"\u003e \u003cp\u003eHardware and software conditions\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c2\"\u003e \u003cp\u003etrain\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c3\"\u003e \u003cp\u003etest\u003c/p\u003e \u003c/th\u003e \u003c/tr\u003e \u003c/thead\u003e \u003ctbody\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eCPU\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c2\"\u003e \u003cp\u003eIntel(R) Xeon(R) Platinum 8255C\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c3\"\u003e \u003cp\u003eIntel(R) Core(TM) i7-8750H\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eGPU\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c2\"\u003e \u003cp\u003eRTX 2080 Ti(11GB)\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c3\"\u003e \u003cp\u003eRTX 1050Ti (4GB)\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eRAM\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c2\"\u003e \u003cp\u003e40GB\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c3\"\u003e \u003cp\u003e16GB\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eOperating system\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c2\"\u003e \u003cp\u003eUbuntu20.4\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c3\"\u003e \u003cp\u003eWindows11\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eCompiled language\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c2\"\u003e \u003cp\u003epython3.8\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c3\"\u003e \u003cp\u003epython3.8\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eDeep learning framework\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c2\"\u003e \u003cp\u003ePyTorch 1.12\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c3\"\u003e \u003cp\u003ePyTorch 1.12\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003c/tbody\u003e \u003c/colgroup\u003e \u003c/table\u003e\u003c/div\u003e \u003c/p\u003e \u003cp\u003e \u003cdiv class=\"gridtable\"\u003e\u003ctable float=\"Yes\" id=\"Tab2\" border=\"1\"\u003e \u003ccaption language=\"En\"\u003e \u003cdiv class=\"CaptionNumber\"\u003eTable 2\u003c/div\u003e \u003cdiv class=\"CaptionContent\"\u003e \u003cp\u003eTraining parameter table\u003c/p\u003e \u003c/div\u003e \u003c/caption\u003e \u003ccolgroup cols=\"3\"\u003e \u003cdiv align=\"left\" class=\"colspec\" colname=\"c1\" colnum=\"1\"\u003e\u003c/div\u003e \u003cdiv align=\"left\" class=\"colspec\" colname=\"c2\" colnum=\"2\"\u003e\u003c/div\u003e \u003cdiv align=\"left\" class=\"colspec\" colname=\"c3\" colnum=\"3\"\u003e\u003c/div\u003e \u003cthead\u003e \u003ctr\u003e \u003cth align=\"left\" colname=\"c1\"\u003e \u003cp\u003eParameter\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c2\"\u003e \u003cp\u003eMeaning\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c3\"\u003e \u003cp\u003eValue\u003c/p\u003e \u003c/th\u003e \u003c/tr\u003e \u003c/thead\u003e \u003ctbody\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eEpochs\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c2\"\u003e \u003cp\u003eNumber of epochs to train for\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c3\"\u003e \u003cp\u003e200\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eBatch\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c2\"\u003e \u003cp\u003eNumber of images per batch\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c3\"\u003e \u003cp\u003e64\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eImgsz\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c2\"\u003e \u003cp\u003eSize of input images as integer or width, height\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c3\"\u003e \u003cp\u003e640\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eOptimizer\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c2\"\u003e \u003cp\u003eOptimizer to use\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c3\"\u003e \u003cp\u003eAdam\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eWorkers\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c2\"\u003e \u003cp\u003eNumber of worker threads used for data loading\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c3\"\u003e \u003cp\u003e8\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003c/tbody\u003e \u003c/colgroup\u003e \u003c/table\u003e\u003c/div\u003e \u003c/p\u003e \u003c/div\u003e \u003cdiv id=\"Sec12\" class=\"Section2\"\u003e \u003ch2\u003e4.2 Comparative experiments of different models\u003c/h2\u003e \u003cp\u003eThe focus of this study is to improve detection speed and reduce model size without compromising detection accuracy. To validate the performance of the improved YOLOv8n with modified detection head in FDM 3D printing, we compared it with mainstream object detection algorithms including Faster R-CNN, YOLOv5n, YOLOv6n, YOLOv8n, and the improved YOLOv8n with modified detection head, all on the same dataset. The solution for the improved YOLOv8n with modified detection head involves using one GroupConv with shared weights. The comparison results are shown in Table\u0026nbsp;\u003cspan refid=\"Tab3\" class=\"InternalRef\"\u003e3\u003c/span\u003e.\u003c/p\u003e \u003cp\u003e \u003cdiv class=\"gridtable\"\u003e\u003ctable float=\"Yes\" id=\"Tab3\" border=\"1\"\u003e \u003ccaption language=\"En\"\u003e \u003cdiv class=\"CaptionNumber\"\u003eTable 3\u003c/div\u003e \u003cdiv class=\"CaptionContent\"\u003e \u003cp\u003eDifferent network test results\u003c/p\u003e \u003c/div\u003e \u003c/caption\u003e \u003ccolgroup cols=\"8\"\u003e \u003cdiv align=\"left\" class=\"colspec\" colname=\"c1\" colnum=\"1\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c2\" colnum=\"2\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c3\" colnum=\"3\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c4\" colnum=\"4\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c5\" colnum=\"5\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c6\" colnum=\"6\"\u003e\u003c/div\u003e \u003cdiv align=\"left\" class=\"colspec\" colname=\"c7\" colnum=\"7\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c8\" colnum=\"8\"\u003e\u003c/div\u003e \u003cthead\u003e \u003ctr\u003e \u003cth align=\"left\" colname=\"c1\"\u003e\u0026nbsp;\u003c/th\u003e \u003cth align=\"left\" colname=\"c2\"\u003e \u003cp\u003ePrecision(P)\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c3\"\u003e \u003cp\u003eRecall(R)\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c4\"\u003e \u003cp\u003emAP50\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c5\"\u003e \u003cp\u003eF1\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c6\"\u003e \u003cp\u003eFPS\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c7\"\u003e \u003cp\u003eParameters\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c8\"\u003e \u003cp\u003eGFLOPs\u003c/p\u003e \u003c/th\u003e \u003c/tr\u003e \u003c/thead\u003e \u003ctbody\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eFaster R-CNN\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e0.867\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0.983\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e \u003cp\u003e0.979\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e \u003cp\u003e0.92\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e \u003cp\u003e2.29\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c7\"\u003e \u003cp\u003e41\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c8\"\u003e \u003cp\u003e251.4\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eYOLOv5n\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e0.923\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0.864\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e \u003cp\u003e0.928\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e \u003cp\u003e0.89\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e \u003cp\u003e77.8\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c7\"\u003e \u003cp\u003e2.5\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c8\"\u003e \u003cp\u003e7.2\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eYOLOv6n\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e0.927\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0.853\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e \u003cp\u003e0.933\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e \u003cp\u003e0.89\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e \u003cp\u003e71.3\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c7\"\u003e \u003cp\u003e4.23\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c8\"\u003e \u003cp\u003e11.9\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eYOLOv8n\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e0.925\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0.921\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e \u003cp\u003e0.968\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e \u003cp\u003e0.92\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e \u003cp\u003e78.4\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c7\"\u003e \u003cp\u003e3.0\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c8\"\u003e \u003cp\u003e8.2\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eImproved head\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e0.939\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0.938\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e \u003cp\u003e0.975\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e \u003cp\u003e0.94\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e \u003cp\u003e92.6\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"left\" colname=\"c7\"\u003e \u003cp\u003e2.35\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c8\"\u003e \u003cp\u003e5.5\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003c/tbody\u003e \u003c/colgroup\u003e \u003c/table\u003e\u003c/div\u003e \u003c/p\u003e \u003cp\u003eThe detection speed metric FPS is an important indicator for evaluating model speed, while mAP50 measures the average precision of the model at a 50% IoU threshold. Average precision refers to calculating the precision of the model for each class at different IoU thresholds and averaging them. The 50% IoU is a common threshold, requiring the overlap area between the detection box and the ground truth box to be at least half of the ground truth box area. mAP50 is a significant metric for assessing the accuracy of object detection models. By constructing a mAP50-FPS plot, we can intuitively observe that the improved YOLOv8n with modified detection head maintains a good average precision while achieving a significant increase in detection speed FPS, as shown in Fig.\u0026nbsp;\u003cspan refid=\"Fig8\" class=\"InternalRef\"\u003e8\u003c/span\u003e.\u003c/p\u003e \u003cp\u003e \u003c/p\u003e \u003cp\u003eIn object detection, GFLOPs are a measure of the computational complexity of a model, representing the total number of floating-point operations performed during the inference process. GFLOPs can be used to assess the computational complexity of different object detection models. In general, models with fewer GFLOPs may be more attractive when computational resources are limited because they may be more suitable for deployment on edge devices or mobile devices. In this study, reducing the size of the model's GFLOPs is crucial for the subsequent deployment of the model on edge devices or mobile devices, as utilizing fewer computational resources is important for deploying the model on FDM 3D printing devices. We visualize the relationship between the computational power required during the detection process and the average precision of detection by plotting the GFLOPs-mAP50 graph, as shown in Fig.\u0026nbsp;\u003cspan refid=\"Fig9\" class=\"InternalRef\"\u003e9\u003c/span\u003e.\u003c/p\u003e \u003cp\u003e \u003c/p\u003e \u003cp\u003eFinally, through comprehensive evaluation of various models based on Precision (P), Recall (R), Mean Average Precision (mAP), F1 score, Frames Per Second (FPS), Parameters, and GFLOPs, it can be observed that the improved detection head of YOLOv8n slightly outperforms other detection models in terms of Precision (P), Recall (R), Mean Average Precision (mAP), and F1 score. Meanwhile, our detection speed has been improved compared to other detection models, and the model's Parameters and GFLOPS have been significantly reduced. By leveraging the lightweight detection head in the improved YOLOv8 model, while maintaining detection accuracy, the overall model parameters are reduced, thereby reducing computational load and significantly improving detection speed.\u003c/p\u003e \u003c/div\u003e \u003cdiv id=\"Sec13\" class=\"Section2\"\u003e \u003ch2\u003e4.3 Improved model verification\u003c/h2\u003e \u003cp\u003eTo explore how lightweight detection heads can achieve optimal detection results, six different detection models based on the YOLOv8n detection head network structure were designed according to the selected improvement schemes. Model 1 represents the original YOLOv8n without any modifications, facilitating comparison with the original network model, while the remaining improvement schemes are shown in Table\u0026nbsp;\u003cspan refid=\"Tab4\" class=\"InternalRef\"\u003e4\u003c/span\u003e.\u003c/p\u003e \u003cp\u003e \u003cdiv class=\"gridtable\"\u003e\u003ctable float=\"Yes\" id=\"Tab4\" border=\"1\"\u003e \u003ccaption language=\"En\"\u003e \u003cdiv class=\"CaptionNumber\"\u003eTable 4\u003c/div\u003e \u003cdiv class=\"CaptionContent\"\u003e \u003cp\u003eConfiguration of different improvement plans\u003c/p\u003e \u003c/div\u003e \u003c/caption\u003e \u003ccolgroup cols=\"3\"\u003e \u003cdiv align=\"left\" class=\"colspec\" colname=\"c1\" colnum=\"1\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c2\" colnum=\"2\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c3\" colnum=\"3\"\u003e\u003c/div\u003e \u003cthead\u003e \u003ctr\u003e \u003cth align=\"left\" colname=\"c1\"\u003e \u003cp\u003eModel number\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c2\"\u003e \u003cp\u003eNumber of 3x3 Conv\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c3\"\u003e \u003cp\u003eNumber of 3x3 GroupConv\u003c/p\u003e \u003c/th\u003e \u003c/tr\u003e \u003c/thead\u003e \u003ctbody\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eModel 1(original model)\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e0\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eModel 2\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e2\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eModel 3\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e1\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eModel 4\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e2\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eModel 5(model we used)\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e1\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eModel 6\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e1\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e1\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003c/tbody\u003e \u003c/colgroup\u003e \u003c/table\u003e\u003c/div\u003e \u003c/p\u003e \u003cp\u003eAfter training the models with the respective approaches, they were validated using the same evaluation criteria as before. The results are shown in Table\u0026nbsp;\u003cspan refid=\"Tab5\" class=\"InternalRef\"\u003e5\u003c/span\u003e.\u003c/p\u003e \u003cp\u003e \u003cdiv class=\"gridtable\"\u003e\u003ctable float=\"Yes\" id=\"Tab5\" border=\"1\"\u003e \u003ccaption language=\"En\"\u003e \u003cdiv class=\"CaptionNumber\"\u003eTable 5\u003c/div\u003e \u003cdiv class=\"CaptionContent\"\u003e \u003cp\u003eValidation results of different improvement approaches\u003c/p\u003e \u003c/div\u003e \u003c/caption\u003e \u003ccolgroup cols=\"8\"\u003e \u003cdiv align=\"left\" class=\"colspec\" colname=\"c1\" colnum=\"1\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c2\" colnum=\"2\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c3\" colnum=\"3\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c4\" colnum=\"4\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c5\" colnum=\"5\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c6\" colnum=\"6\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c7\" colnum=\"7\"\u003e\u003c/div\u003e \u003cdiv align=\"char\" char=\".\" class=\"colspec\" colname=\"c8\" colnum=\"8\"\u003e\u003c/div\u003e \u003cthead\u003e \u003ctr\u003e \u003cth align=\"left\" colname=\"c1\"\u003e\u0026nbsp;\u003c/th\u003e \u003cth align=\"left\" colname=\"c2\"\u003e \u003cp\u003ePrecision(P)\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c3\"\u003e \u003cp\u003eRecall(R)\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c4\"\u003e \u003cp\u003emAP50\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c5\"\u003e \u003cp\u003eF1\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c6\"\u003e \u003cp\u003eFPS\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c7\"\u003e \u003cp\u003eParameters\u003c/p\u003e \u003c/th\u003e \u003cth align=\"left\" colname=\"c8\"\u003e \u003cp\u003eGFLOPs\u003c/p\u003e \u003c/th\u003e \u003c/tr\u003e \u003c/thead\u003e \u003ctbody\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eModel 1\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e0.925\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0.921\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e \u003cp\u003e0.968\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e \u003cp\u003e0.92\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e \u003cp\u003e78.4\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c7\"\u003e \u003cp\u003e3.0\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c8\"\u003e \u003cp\u003e8.2\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eModel 2\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e0.928\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0.868\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e \u003cp\u003e0.961\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e \u003cp\u003e0.90\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e \u003cp\u003e80.5\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c7\"\u003e \u003cp\u003e3.8\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c8\"\u003e \u003cp\u003e8.2\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eModel 3\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e0.893\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0.932\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e \u003cp\u003e0.959\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e \u003cp\u003e0.91\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e \u003cp\u003e86.5\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c7\"\u003e \u003cp\u003e3.0\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c8\"\u003e \u003cp\u003e6.7\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eModel 4\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e0.912\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0.906\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e \u003cp\u003e0.964\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e \u003cp\u003e0.91\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e \u003cp\u003e80.2\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c7\"\u003e \u003cp\u003e2.4\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c8\"\u003e \u003cp\u003e5.8\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eModel 5\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e0.939\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0.938\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e \u003cp\u003e0.975\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e \u003cp\u003e0.94\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e \u003cp\u003e92.6\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c7\"\u003e \u003cp\u003e2.35\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c8\"\u003e \u003cp\u003e5.5\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd align=\"left\" colname=\"c1\"\u003e \u003cp\u003eModel 6\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c2\"\u003e \u003cp\u003e0.927\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c3\"\u003e \u003cp\u003e0.883\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c4\"\u003e \u003cp\u003e0.946\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c5\"\u003e \u003cp\u003e0.90\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c6\"\u003e \u003cp\u003e82.7\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c7\"\u003e \u003cp\u003e3.1\u003c/p\u003e \u003c/td\u003e \u003ctd align=\"char\" char=\".\" colname=\"c8\"\u003e \u003cp\u003e6.9\u003c/p\u003e \u003c/td\u003e \u003c/tr\u003e \u003c/tbody\u003e \u003c/colgroup\u003e \u003c/table\u003e\u003c/div\u003e \u003c/p\u003e \u003cp\u003eBy comparing the Precision, Recall, mAP50, F1 score, FPS, Parameters, and GFLOPs of each approach, we comprehensively evaluated the performance of the models. It can be observed that model 5 (1 GroupConv) outperforms other approaches in all aspects. The mAP50 of model 5 is 0.7% higher than that of the original YOLOv8n, indicating a slight improvement in detection accuracy compared to the original YOLOv8n. Additionally, the FPS and GFLOPs of model 5 have increased by 18.1% and decreased by 32.9%, respectively. This suggests that model 5 can achieve higher accuracy and detection speed with less computational resources compared to the original YOLOv8n, which is crucial for real-time detection and accuracy in FDM 3D printing. Additionally, this ensures that the model can be effectively deployed on platforms with lower computational power or embedded devices.\u003c/p\u003e \u003c/div\u003e"},{"header":"5. Real-time defect detection system","content":"\u003cdiv id=\"Sec15\"\u003e\n \u003ch2\u003e5.1 Detection system hardware conditions\u003c/h2\u003e\n \u003cp\u003eThe hardware requirements of the detection system refer to the conditions of the acquisition device, as shown in Fig. \u003cspan\u003e10\u003c/span\u003e. This detection system consists of three parts: firstly, a 3D printer that performs 3D printing tasks, capable of executing G-Code to achieve 3D printing; secondly, an image acquisition device that utilizes an industrial camera in conjunction with a ring light source to obtain clear real-time printing images, which are then inputted into the computer; finally, a computer equipped with real-time detection software, which processes real-time images captured by the acquisition device using detection algorithms to achieve real-time detection of defects during the printing process. It is worth noting that both the 3D printer and the industrial camera are readily available devices on the market, demonstrating the versatility of this system; the computer configuration is identical to that of the hardware setup in Section 4.1, highlighting the system\u0026apos;s ability to achieve real-time detection even under low computational power conditions.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"Sec16\"\u003e\n \u003ch2\u003e5.2 Detection system software detection process\u003c/h2\u003e\n \u003cp\u003eThe real-time detection system, developed using PyQt5 and open-source computer vision libraries, achieves functionalities such as online image acquisition, visualization of the detection process, browsing of detection results, and defect warning. Thanks to the powerful performance of the improved YOLOv8 model for the detection head, defect detection can be carried out with input images simply converted to grayscale before detection. This significantly reduces the image preprocessing process and minimizes the utilization of computational resources.\u003c/p\u003e\n \u003cp\u003eThe real-time detection process algorithm is illustrated in Fig. \u003cspan\u003e11\u003c/span\u003e. When the 3D printer initiates printing, the industrial camera begins capturing images. These images are collected in real-time, saved, and converted to grayscale. The improved YOLOv8 model of the detection head analyzes the grayscale images of the printed object to detect defects. If no defects are found, the grayscale images of the printed object are re-evaluated after a set interval. However, if defects are detected, the printing process is halted.\u003c/p\u003e\n \u003cp\u003eThe detection system, as shown in Fig. \u003cspan\u003e12\u003c/span\u003e, encompasses the following functionalities:\u003c/p\u003e\n \u003cp\u003eInitialization: Searches and selects connected cameras, and toggles device power on or off.\u003c/p\u003e\n \u003cp\u003eCollecting: Adjusts camera capture mode (continuous or trigger mode), starts or stops collecting, and saves captured image data.\u003c/p\u003e\n \u003cp\u003eParameters: Retrieves and sets camera parameters, including exposure, gain, and frame rate adjustments.\u003c/p\u003e\n \u003cp\u003eDetection: Sets detection time intervals, initiates detection, and prints detection results.\u003c/p\u003e\n \u003cp\u003eThe software detection process proceeds as follows: Firstly, it acquires online camera devices and opens them to obtain images, defaulting to continuous capture mode. It adjusts camera exposure, gain, and frame rate parameters to ensure clear image capture. Detection intervals are set to periodically inspect printed object defects. Finally, the detected defect types are printed, and defect images are displayed in the bottom right corner of the interface.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"Sec17\"\u003e\n \u003ch2\u003e5.3 Practical application results\u003c/h2\u003e\n \u003cp\u003eThe application scenario demonstrates the real-time monitoring of defects during the printing process, accurately identifying defects across five different types, as shown in Fig. \u003cspan\u003e13\u003c/span\u003e. Specifically, (a), (b), (c), (d), and (e) correspond to curling, cracking, stringing, layer misalignment, and platform detachment defects, respectively. The detection system promptly and accurately identifies defects occurring during the printing process. By continuously monitoring and accurately identifying these defects in real-time, timely corrective measures can be taken to improve printing quality and efficiency, thereby reducing resource wastage.\u003c/p\u003e\n\u003c/div\u003e"},{"header":"6. Conclusion","content":"\u003cp\u003eBy comparing mainstream object detection algorithms for FDM 3D printing defect detection, we find that the current YOLOv8n detection algorithm achieves excellent detection accuracy. However, in practical production settings for FDM 3D printing, high computational power platforms are not always ideal. Therefore, a lightweight model with high detection accuracy and fast detection speed is essential for defect detection in FDM 3D printing.\u003c/p\u003e \u003cp\u003eWe have improved the YOLOv8n detection head to enhance detection speed and reduce model size while maintaining detection accuracy for real-time defect detection in FDM 3D printing. The improved detection head reduces convolutional volume by sharing weights and further enhances detection speed and reduces computational power by introducing group convolution. We evaluated the proposed method using a real FDM 3D printing defect dataset. Experimental results show that the method achieves high detection accuracy (mAP50\u0026thinsp;=\u0026thinsp;0.975) and detection speed (approximately 92.4 FPS), meeting the requirements of real-time defect detection. Additionally, our model has a parameter size of 2.35M, making it lighter than the original YOLOv8n model. We also designed a real-time detection system based on the improved YOLOv8n detection head model, which includes real-time image acquisition and real-time defect detection during printing.\u003c/p\u003e \u003cp\u003eAlthough the method based on the improved YOLOv8n detection head provides a feasible solution for real-time defect detection, it still has certain limitations in dealing with various complex scenarios and defects in different material prints. Future research can focus on enhancing detection robustness and generalization ability through more diverse data augmentation and model optimization. With the development of IoT technology, intelligent manufacturing systems will become an essential part of future factories. In this context, integrating real-time defect detection with automated production lines to achieve a closed-loop system of defect detection and timely feedback repair will be a challenging yet highly promising direction. Therefore, future research can explore how to integrate lightweight detection models with intelligent manufacturing systems to achieve more efficient and intelligent production processes.\u003c/p\u003e"},{"header":"Declarations","content":"\u003cp\u003eAcknowledgment\u003c/p\u003e\n\u003cp\u003eThis research was supported by Key R\u0026amp;D projects in Zhejiang Province (No. 2024C01042).\u003c/p\u003e\n\u003cp\u003eCompeting Interests:The authors declare no competing interests.\u003c/p\u003e\n\u003cp\u003eData availability\u003c/p\u003e\n\u003cp\u003eData will be available from corresponding author upon reasonable request.\u003c/p\u003e\n"},{"header":"References","content":"\u003col\u003e\n\u003cli\u003eInzana JA, Olvera D, Fuller SM, et al (2014) 3D printing of composite calcium phosphate and collagen scaffolds for bone regeneration. Biomaterials 35:4026\u0026ndash;4034. https://doi.org/10.1016/j.biomaterials.2014.01.064\u003c/li\u003e\n\u003cli\u003eDebRoy T, Wei HL, Zuback JS, et al (2018) Additive manufacturing of metallic components \u0026ndash; Process, structure and properties. Progress in Materials Science 92:112\u0026ndash;224. https://doi.org/Associated Composite\u003c/li\u003e\n\u003cli\u003eWickramasinghe S, Do T, Tran P (2020) FDM-Based 3D Printing of Polymer and Associated Composite: A Review on Mechanical Properties, Defects and Treatments. Polymers 12:1529. https://doi.org/10.3390/polym12071529\u003c/li\u003e\n\u003cli\u003eLigon SC, Liska R, Stampfl J, et al (2017) Polymers for 3D Printing and Customized Additive Manufacturing. Chem Rev 117:10212\u0026ndash;10290. https://doi.org/10.1021/acs.chemrev.7b00074\u003c/li\u003e\n\u003cli\u003ePenumakala PK, Santo J, Thomas A (2020) A critical review on the fused deposition modeling of thermoplastic polymer composites. Composites Part B: Engineering 201:108336. https://doi.org/10.1016/j.compositesb.2020.108336\u003c/li\u003e\n\u003cli\u003eNgo TD, Kashani A, Imbalzano G, et al (2018) Additive manufacturing (3D printing): A review of materials, methods, applications and challenges. Composites Part B: Engineering 143:172\u0026ndash;196. https://doi.org/10.1016/j.compositesb.2018.02.012\u003c/li\u003e\n\u003cli\u003eAwasthi P, Banerjee SS (2021) Fused deposition modeling of thermoplastic elastomeric materials: Challenges and opportunities. Additive Manufacturing 46:102177. https://doi.org/10.1016/j.addma.2021.102177\u003c/li\u003e\n\u003cli\u003eFerretti P, Leon-Cardenas C, Santi GM, et al (2021) Relationship between FDM 3D Printing Parameters Study: Parameter Optimization for Lower Defects. Polymers 13:2190. https://doi.org/10.3390/polym13132190\u003c/li\u003e\n\u003cli\u003eBaumann F, Roller D (2016) Vision based error detection for 3D printing processes. MATEC Web of Conferences 59:06003. https://doi.org/10.1051/matecconf/20165906003\u003c/li\u003e\n\u003cli\u003eBhavsar P, Sharma B, Moscoso-Kingsley W, Madhavan V (2020) Detecting first layer bond quality during FDM 3D printing using a discrete wavelet energy approach. Procedia Manufacturing 48:718\u0026ndash;724. https://doi.org/10.1016/j.promfg.2020.05.104\u003c/li\u003e\n\u003cli\u003eLopes TG, Aguiar PR, Monson PMDC, et al (2023) Machine condition monitoring in FDM based on electret microphone, SVM, and neural networks. Int J Adv Manuf Technol 129:1769\u0026ndash;1786. https://doi.org/10.1007/s00170-023-12375-0\u003c/li\u003e\n\u003cli\u003eZhao X, Lian Q, He Z, Zhang S (2020) Region-based online flaw detection of 3D printing via fringe projection. Meas Sci Technol 31:035011. https://doi.org/10.1088/1361-6501/ab524b\u003c/li\u003e\n\u003cli\u003eLi X-Y, Liu F-L, Zhang M-N, et al (2023) A Combination of Vision- and Sensor-Based Defect Classifications in Extrusion-Based Additive Manufacturing. Journal of Sensors 2023:1\u0026ndash;13. https://doi.org/10.1155/2023/1441936\u003c/li\u003e\n\u003cli\u003eYean FP, Chew WJ (2024) Detection of Spaghetti and Stringing Failure in 3D Printing. In: 2024 International Conference on Green Energy, Computing and Sustainable Technology (GECOST). IEEE, Miri Sarawak, Malaysia, pp 293\u0026ndash;298\u003c/li\u003e\n\u003cli\u003eShen H, Sun W, Fu J (2019) Multi-view online vision detection based on robot fused deposit modeling 3D printing technology. Rapid Prototyping Journal 25:343\u0026ndash;355. https://doi.org/10.1108/RPJ-03-2018-0052\u003c/li\u003e\n\u003cli\u003eZhao X, Li Q, Xiao M, He Z (2023) Defect detection of 3D printing surface based on geometric local domain features. Int J Adv Manuf Technol 125:183\u0026ndash;194. https://doi.org/10.1007/s00170-022-10662-w\u003c/li\u003e\n\u003cli\u003eHolzmond O, Li X (2017) In situ real time defect detection of 3D printed parts. Additive Manufacturing 17:135\u0026ndash;142. https://doi.org/10.1016/j.addma.2017.08.003\u003c/li\u003e\n\u003cli\u003eKumar S, Kolekar T, Patil S, et al (2022) A Low-Cost Multi-Sensor Data Acquisition System for Fault Detection in Fused Deposition Modelling. Sensors 22:517. https://doi.org/10.3390/s22020517\u003c/li\u003e\n\u003cli\u003eRettenberger L, Beyer N, Sieber I, Reischl M (2024) Fault Detection in 3D-Printing with Deep Learning. In: 2024 IEEE International Conference on Consumer Electronics (ICCE). IEEE, Las Vegas, NV, USA, pp 1\u0026ndash;4. https://doi.org/10.1109/ICCE59016.2024.10444198\u003c/li\u003e\n\u003cli\u003eZhang H, Zong Z, Yao Y, et al (2023) Multi-Axis 3D Printing Defect Detecting by Machine Vision with Convolutional Neural Networks. Exp Tech 47:619\u0026ndash;631. https://doi.org/10.1007/s40799-022-00577-2\u003c/li\u003e\n\u003cli\u003eFarhan Khan M, Alam A, Ateeb Siddiqui M, et al (2021) Real-time defect detection in 3D printing using machine learning. Materials Today: Proceedings 42:521\u0026ndash;528. https://doi.org/10.1016/j.matpr.2020.10.482\u003c/li\u003e\n\u003cli\u003eZhang Y, Zhang Z, Fu K, Luo X (2022) Adaptive Defect Detection for 3-D Printed Lattice Structures Based on Improved Faster R-CNN. IEEE Trans Instrum Meas 71:1\u0026ndash;9. https://doi.org/10.1109/TIM.2022.3200362\u003c/li\u003e\n\u003cli\u003eXu L, Zhang X, Ma F, et al (2023) Detecting defects in fused deposition modeling based on improved YOLO v4. Mater Res Express 10:095304. https://doi.org/10.1088/2053-1591/acf6f9\u003c/li\u003e\n\u003cli\u003eParaskevoudis K, Karayannis P, Koumoulos EP (2020) Real-Time 3D Printing Remote Defect Detection (Stringing) with Computer Vision and Artificial Intelligence. Processes 8:1464. https://doi.org/10.3390/pr8111464\u003c/li\u003e\n\u003cli\u003eKim H, Lee H, Ahn S-H (2022) Systematic deep transfer learning method based on a small image dataset for spaghetti-shape defect monitoring of fused deposition modeling. Journal of Manufacturing Systems 65:439\u0026ndash;451. https://doi.org/10.1016/j.jmsy.2022.10.009\u003c/li\u003e\n\u003cli\u003eKozhay K, Turarbek S, Asselbekova T, et al (2024) Convolutional Neural Network-Based Defect Detection Technique in FDM Technology. Procedia Computer Science 231:119\u0026ndash;128. https://doi.org/10.1016/j.procs.2023.12.183\u003c/li\u003e\n\u003cli\u003eG\u0026uuml;naydın, K., \u0026amp; T\u0026uuml;rkmen, H. S. (2018). Common FDM 3D printing defects. In International congress on 3D printing (additive manufacturing) technologies and digital industry. No. April 2018, pp. 19-21\u003c/li\u003e\n\u003cli\u003eBaechle-Clayton M, Loos E, Taheri M, Taheri H (2022) Failures and Flaws in Fused Deposition Modeling (FDM) Additively Manufactured Polymers and Composites. J Compos Sci 6:202. https://doi.org/10.3390/jcs6070202\u003c/li\u003e\n\u003cli\u003eJocher, G., Chaurasia, A., Qiu, J.: YOLO by Ultralytics (2023)\u003c/li\u003e\n\u003cli\u003eKrizhevsky A, Sutskever I, Hinton GE (2017) ImageNet classification with deep convolutional neural networks. Commun ACM 60:84\u0026ndash;90. https://doi.org/10.1145/3065386\u003c/li\u003e\n\u003c/ol\u003e"}],"fulltextSource":"","fullText":"","funders":[],"hasAdminPriorityOnWorkflow":false,"hasManuscriptDocX":true,"hasOptedInToPreprint":true,"hasPassedJournalQc":"","hasAnyPriority":false,"hideJournal":false,"highlight":"","institution":"","isAcceptedByJournal":true,"isAuthorSuppliedPdf":false,"isDeskRejected":"","isHiddenFromSearch":false,"isInQc":false,"isInWorkflow":false,"isPdf":false,"isPdfUpToDate":true,"isWithdrawnOrRetracted":false,"journal":{"display":true,"email":"
[email protected]","identity":"the-international-journal-of-advanced-manufacturing-technology","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":false,"externalIdentity":"jamt","sideBox":"Learn more about [The International Journal of Advanced Manufacturing Technology](https://www.springer.com/journal/170)","snPcode":"170","submissionUrl":"https://submission.nature.com/new-submission/170/3","title":"The International Journal of Advanced Manufacturing Technology","twitterHandle":"","acdcEnabled":true,"dfaEnabled":true,"editorialSystem":"em","reportingPortfolio":"Springer Hybrid","inReviewEnabled":true,"inReviewRevisionsEnabled":false},"keywords":"FDM 3D printing, Real-time defect detection, Object detection, Group Convolution, Lightweight detection head","lastPublishedDoi":"10.21203/rs.3.rs-4380689/v1","lastPublishedDoiUrl":"https://doi.org/10.21203/rs.3.rs-4380689/v1","license":{"name":"CC BY 4.0","url":"https://creativecommons.org/licenses/by/4.0/"},"manuscriptAbstract":"\u003cp\u003eFDM 3D printing is one of the most widely used additive manufacturing methods, bringing great convenience to production manufacturing. However, various printing defects may occur during the printing process due to human factors or printer-related issues. Timely detection of defects and halting printing becomes a scenario of significant practical importance. This paper first analyzes the causes of the five most common defects in FDM 3D printing, and a defect dataset is created by deliberately designing defects. Subsequently, a real-time defect detection system for FDM 3D printing, based on an improved YOLOv8 detection head, is developed. By employing an optimization method using Group Convolution to share parameters, the detection head is lightweight, resulting in better model performance. Experimental results demonstrate that the mAP50 of the improved YOLOv8 model reaches 97.5%, with an 18.1% increase in FPS and a 32.9% reduction in GFLOPs. This enhancement maintains comparable detection accuracy to the original model while achieving faster detection speed and lower computational requirements. The improved model is integrated into the detection system as the detection model, and through testing, the real-time detection system promptly and accurately identifies and alerts any occurring defects. The practical significance of this system lies in its ability to enhance production efficiency, reduce resource wastage due to defective printing, and improve product quality and manufacturing safety, thereby providing strong support for the application of visual inspection technology in FDM 3D printing.\u003c/p\u003e","manuscriptTitle":"Real-time defect detection for FDM 3D printing using lightweight model deployment","msid":"","msnumber":"","nonDraftVersions":[{"code":1,"date":"2024-05-24 10:05:06","doi":"10.21203/rs.3.rs-4380689/v1","editorialEvents":[{"type":"communityComments","content":0},{"type":"decision","content":"Minor Revisions Needed","date":"2024-08-27T04:19:19+00:00","index":"","fulltext":""},{"type":"reviewerAgreed","content":"","date":"2024-05-16T19:35:59+00:00","index":0,"fulltext":""},{"type":"reviewersInvited","content":"","date":"2024-05-16T09:12:18+00:00","index":"","fulltext":""},{"type":"editorAssigned","content":"","date":"2024-05-08T04:08:05+00:00","index":"","fulltext":""},{"type":"submitted","content":"The International Journal of Advanced Manufacturing Technology","date":"2024-05-07T02:30:14+00:00","index":"","fulltext":""}],"status":"published","journal":{"display":true,"email":"
[email protected]","identity":"the-international-journal-of-advanced-manufacturing-technology","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":false,"externalIdentity":"jamt","sideBox":"Learn more about [The International Journal of Advanced Manufacturing Technology](https://www.springer.com/journal/170)","snPcode":"170","submissionUrl":"https://submission.nature.com/new-submission/170/3","title":"The International Journal of Advanced Manufacturing Technology","twitterHandle":"","acdcEnabled":true,"dfaEnabled":true,"editorialSystem":"em","reportingPortfolio":"Springer Hybrid","inReviewEnabled":true,"inReviewRevisionsEnabled":false}}],"origin":"","ownerIdentity":"53f6e911-8aa8-42bc-a144-d3524ed9f8e4","owner":[],"postedDate":"May 24th, 2024","published":true,"recentEditorialEvents":[],"rejectedJournal":[],"revision":"","amendment":"","status":"published-in-journal","subjectAreas":[],"tags":[],"updatedAt":"2024-09-23T16:11:46+00:00","versionOfRecord":{"articleIdentity":"rs-4380689","link":"https://doi.org/10.1007/s00170-024-14452-4","journal":{"identity":"the-international-journal-of-advanced-manufacturing-technology","isVorOnly":false,"title":"The International Journal of Advanced Manufacturing Technology"},"publishedOn":"2024-09-17 15:58:02","publishedOnDateReadable":"September 17th, 2024"},"versionCreatedAt":"2024-05-24 10:05:06","video":"","vorDoi":"10.1007/s00170-024-14452-4","vorDoiUrl":"https://doi.org/10.1007/s00170-024-14452-4","workflowStages":[]},"version":"v1","identity":"rs-4380689","journalConfig":"researchsquare"},"__N_SSP":true},"page":"/article/[identity]/[[...version]]","query":{"redirect":"/article/rs-4380689","identity":"rs-4380689","version":["v1"]},"buildId":"qtupq5eGEP_6zYnWcrvyt","isFallback":false,"isExperimentalCompile":false,"dynamicIds":[84888],"gssp":true,"scriptLoader":[]}
Text is read by the "Ask this paper" AI Q&A widget below.
Extraction quality varies by source — PMC NXML preserves structure
cleanly, OA-HTML may include some navigation residue, and OA-PDF can
have broken hyphenation. The publisher copy
(via DOI)
is the canonical version.