## 5 Results  
To avoid distorting the results or creating a bias, only the test dataset was examined in more detail and used for the evaluation. However, TF does not include a function to output the F1 score, so a separate category had to be implemented for this. An evaluation script was used to compare the results of all model iterations and the results are shown in Table 3.  
The results in the table clearly show how the performance of the model could be improved by adding new layers and adjusting the parameters. Accuracy was increased from 72.32% in the base model to 99.11% in the final model architecture by adding the WCE loss function, the learning rate scheduling, and the Sobel filter layer. After 10 epochs, the final model also achieved a 99.1% precision and an F1 score of 99.1%. During the evaluation of the model, Grad-CAM heat maps were rendered for each image to provide insight into the model's predictions. Gradient Weighted Class Activation Mapping is a class-discriminative localization technique that makes any convolutional neural network model more transparent by providing visual explanations [84]. This method, implemented via the \"make_gradcam_heatmap\" function, highlights sections that have significantly influenced the model's prediction. This function takes four inputs as the image to be scored, the last layer of the model, the trained network, and the value of the predicted class to generate the explanatory heatmap. Gradients are calculated using the TF's GradientTape function, a tool that documents operations for automated differentiation. Figure 13: Final model architecture. After the rescaling layer, the Sobel filtering layer was implemented. Compared to the base model architecture, this final iteration of the CNN also uses an additional Conv2D convolutional layer and ReLu activation function, and another MaxPooling2D layer for non-linear down sampling. \begin{table}
\begin{tabular}{l c c c c} \hline \hline
**Model Architecture** & **Loss** & **Accuracy** & **Precision** & **F1 Score** & **Epochs** \\ \hline Basic & 0.0002 & 0.7233 & 0.7233 & 0.7233 & 15 \\ + Weighted cross-entropy & \textless{}0.0001 & 0.9838 & 0.9846 & 0.9835 & 10 \\ + Learning rate scheduling & \textless{}0.0001 & 0.9852 & 0.9886 & 0.9847 & 15 \\ + Sobel layer & \textless{}0.0001 & 0.9912 & 0.9910 & 0.9911 & 10 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Results of all model iterations. It determines the gradients of the predicted class in relation to the output of the previous layer. The function averages the calculated gradients over each feature map in the output of the last convolutional layer, producing a set of individual weights for each feature map used. The feature maps are then multiplied by the assigned weights to produce weighted feature maps. A visual heatmap per class is then created by using the output images from the previous layer and calculating their weighted sum by averaging the resulting maps across all channels. The Grad-CAM images generated for each frame during the evaluation provided a visual explanation of the classification process. The randomized evaluation of these heatmaps clearly showed that the correct areas were marked and that the accuracies listed in Table 2 were correct and not due to false convergence. The Grad-CAM heatmaps make the classification of the CNN comprehensible and visually highlight the areas that were crucial for the prediction results. In order to assess the actual usability of the custom CNNs used, a random comparison of the original frames with the Grad-CAM heat maps was performed, as shown in Figure 14. As can be clearly seen, all images without defects were classified as \"True: ok\" and \"Predicted: ok\". In contrast, the images with a detected defect were classified as \"True: defect\" and \"Predicted: defect\".