## 6 Discussion  
This paper proposes an approach for real-time process monitoring and in situ defect detection in PBF-LB/P using a low-cost camera solution and a custom Convolutional Neural Network for data analysis and defect prediction. As previous studies have shown, the artificial creation of defects in powder bed fusion is severely limited by the ability to manipulate the process parameters, so new ways must be found to simulate these  
Figure 14: Comparison of some original frames (**a**) with the corresponding Grad-CAM heatmaps (**b**) after classification. The evaluation of the Grad-CAM heatmaps clearly shows that the custom CNN classified correctly even over several design jobs with different component geometries. Even components with similar geometry to the actual defect were not classified as defects. defects and further investigate their effects on the process. These approaches have shown promising results in the generation of curling and the detection of this effect via sensory measurement of the powder bed using laser profilometry, as shown in [24; 25], and process monitoring using thermal imaging and CNN [35]. In order to investigate the effects of other defects on the process, a new method had to be developed that would influence the process in an independent mechanical way without causing a process termination. This is the only way to take a further step towards holistic process monitoring via defect detection. A mechanical assembly was therefore developed and mounted on the coater blade, which then penetrates the powder bed to a defined depth in a reproducible manner via an external actuator system. Controlled via a Raspberry Pi and triggered by an end switch on the coating blade actuator, the defects were randomly generated and the test series could then be run over several build jobs without the need for human intervention. Many of the approaches discussed in Section 2 have already shown that deep learning computer vision is a mature method for monitoring various manufacturing processes, using supervised, unsupervised, GAN, and hybrid convolutional neural networks to detect or predict various defects. The use of a CNN enables the automated detection and segmentation of objects by learning spatial hierarchies of features from low to high-level patterns. In this case, a camera solution based on a Raspberry Pi Camera Module 2 was used to generate the data for training a CNN. In order to generate as much and as varied data as possible to train the CNN, several processes were filmed and the individual frames were automatically labelled via a separate interface triggered by the defect generation. The chosen camera system is low cost but offers a resolution of up to 8 MP. However, it was found that the resolution had less of an impact on the defects detected than the illumination, so the full capabilities of the camera were never used. This can be explained via the use of several filters and abstraction by means of a Sobel filter, depending on the model chosen. If, for certain applications (e.g., very small defects), the resolution were to be blamed for the poor performance, this approach would allow it to be increased simply by modifying the code, but in the setting chosen, this was not necessary, and both the file size and processing speed were favored. There are already many well-known CNN model architectures [85] that can be used to classify the different tasks [86] and have been proposed in several studies as already discussed. In this study, a custom CNN has been proposed whose architecture is based on a standard model that includes Conv2D layers, MaxPooling2D layers, flattening, and fully connected dense layers to output two possible classes, indicating the model's prediction of the input image class (0 or 1). The basic architecture was then gradually adapted and extended to achieve continuous performance improvements. To avoid class imbalance, the weighted cross-entropy loss function was added, increasing the accuracy from 72% for the base model to 98%.