# Real-Time Detection of Hole-Type Defects on Industrial Components Using Raspberry Pi 5
## 4 Results and Real-Time Deployment
### MobileNetV3  
MobileNetV3-Large architecture was fine-tuned for binary defect classification with a strong emphasis on lightweight deployment and inference efficiency. The training process utilized a two-stage fine-tuning strategy, beginning with classifier head training followed by unfreezing all layers for full backpropagation. Weighted cross-entropy loss was employed to counteract dataset imbalance, and the model was trained using mixed precision for improved throughput. Data augmentation techniques, including random rotation, horizontal flip, brightness/contrast jittering, and Gaussian noise, were applied to improve generalization. The model was evaluated on a 6523-image test set extracted from a larger corpus of 43,482 grayscale industrial images.  
The training and validation curves of MobileNetV3-Large (Figure 9) demonstrate rapid convergence and strong generalization. Training loss exhibited a consistent exponential decline over epochs, while training accuracy steadily approached 100%. Validation accuracy increased rapidly in early epochs and stabilized near-perfect levels (>99.9%), with validation loss concurrently decreasing and plateauing below 0.02. The close alignment between training and validation metrics without divergence indicates an absence of overfitting. These trends confirm the effectiveness of the two-stage fine-tuning strategy and regularization through augmentation and class balancing.  
Figure 8: Grad-CAM visualizations for ResNet50 incorrect predictions with activation concentrated on irregular or anomalous areas. The color gradient from blue to red represents increasing importance in the model’s decision-making, with red indicating the highest influence.  
To support interpretability and explain the decision-making behavior of MobileNetV3-Large, Grad-CAM visualizations were generated for both correctly and incorrectly classified samples (Figures 10 and 11). For true positive predictions, the model's attention was concentrated on semantically meaningful features such as hole alignment, plate boundaries, and surface inconsistencies, indicating that its decisions are grounded in visually relevant defect indicators. In non-defective samples, attention maps exhibited diffuse and uniform activation across structurally consistent regions, reflecting model confidence in the absence of anomalies.  
Grad-CAM maps for false positives (i.e., defect predicted for non-defective parts) revealed that the model focused on ambiguous regions such as lighting gradients, smudges, or subtle textures, suggesting a conservative detection behavior that prioritizes defect sensitivity over specificity. While this results in a small number of overcautious classifications, such behavior may be desirable in industrial inspection systems where false negatives carry higher operational risk than false positives. Grad-CAM visualizations further validated the model's decision-making process, revealing precise attention to regions of interest such as corner irregularities, misplaced holes, or homogeneous surfaces in no-defect parts. Unlike larger models, MobileNetV3-Large demonstrated both excellent interpretability and minimal overfitting while maintaining ultra-low latency. These results establish it as a compelling choice for real-time, resource-constrained industrial defect detection systems.  
Figure 9: Training and validation accuracy/loss curves for MobileNetV3-Large.  
Figure 10: Grad-CAM visualizations for EfficientNet-B3 predictions on correctly classified samples with activation concentrated on irregular or anomalous areas. The color gradient from blue to red represents increasing importance in the model’s decision-making, with red indicating the highest influence.