# Real-Time Detection of Hole-Type Defects on Industrial Components Using Raspberry Pi 5
## 4 Results and Real-Time Deployment
### EfficientNetB3  
EfficientNet-B3 was fine-tuned for binary classification of defective and non-defective industrial components, with an emphasis on balancing model complexity and inference accuracy. The training utilized the full model architecture initialized with pretrained weights and applied weighted cross-entropy loss to mitigate class imbalance. Training was conducted using mixed-precision computation to accelerate convergence and reduce GPU memory usage. EfficientNet-B3 achieved near-perfect classification performance, attaining 99.97% test accuracy with a test loss of only 0.0009. Training and validation curves (Figure 12) exhibit a smooth convergence pattern, with training loss declining progressively and training accuracy consistently improving across epochs. Validation accuracy rapidly exceeded 99.9% early in the training process and plateaued at near-perfect levels, while validation loss remained minimal and stable. The  
Figure 11: Grad-CAM visualizations for MobileNetV3-Large model predictions. All samples shown are false positives where the model predicted a defect despite the ground truth being \"no defect\". The color gradient from blue to red represents increasing importance in the model’s decision-making, with red indicating the highest influence. tight alignment between training and validation metrics indicates excellent generalization and confirms the absence of overfitting. To enhance interpretability and explain the model's decision-making process, Grad-CAM visualizations were generated for both accurate and misclassified test samples (Figure 13). For correctly predicted defect samples, the model's attention was sharply localized to discriminative regions such as edge discontinuities, corner irregularities, and surface anomalies. For non-defective parts, the attention maps revealed widespread, diffuse activations across smooth surface areas, suggesting strong confidence in the absence of defects. In the only false positive case, the model's attention focused on ambiguous features resembling defect patterns, such as surface reflections or shadow gradients, indicating a conservative bias favoring defect sensitivity. Feature maps extracted from different convolutional stages revealed a hierarchical learning process, where early layers captured general contours while deeper layers localized fine-grained defect features. Compared to lightweight architecture, EfficientNet-B3 offered superior accuracy and interpretability while maintaining a practical inference speed for real-time deployment in industrial quality assurance pipelines. Figure 12: Training and validation accuracy/loss curves for EfficientNet-B3. The heatmaps highlight the discriminative regions that influenced the model's decision. Red zones indicate high attention. Correctly classified defects show strong localization on holes or irregular edges, while non-defective parts exhibit dispersed activation. The bottom-right image illustrates a false positive case where the model attended to ambiguous surface artifacts. These results demonstrate the model's interpretability and its capacity to focus on semantically relevant features for classification. To evaluate and compare the binary classification performance of the proposed models, confusion matrices for ResNet50, MobileNetV3, and EfficientNetB3 were generated and are illustrated in Figure 14. All three models demonstrated strong performance in accurately identifying defective and non-defective samples from the test dataset. The ResNet50 model achieved near-perfect results, correctly classifying all defective samples and misclassifying only a single OK sample as defective, yielding the best performance in terms of both false positives and false negatives. MobileNetV3 followed closely, also achieving flawless detection of defective items but with four OK instances incorrectly labeled as defective.