# Real-Time Detection of Hole-Type Defects on Industrial Components Using Raspberry Pi 5
## 4 Results and Real-Time Deployment
### Real-Time Testing  
To evaluate the model's performance in a deployment scenario, the trained model was exported to TorchScript and quantized for real-time inference. This phase assessed real-time performance using lightweight models deployed on a Raspberry Pi 5. A total of 100 test samples were evaluated under live streaming conditions via webcam input. Models were converted to TorchScript for optimized inference. OpenCV pipelines handled real-time image capture, preprocessing, and display. Real-Time Testing Procedure:  
1. A live video stream was initialized via the camera module. 2. Each frame was resized, normalized, and passed through the quantized model. 3. The prediction result (Defect/No Defect) and inference time were displayed on the live feed. 4. A total of 100 samples were evaluated during testing, simulating real inspection use cases. The real-time evaluation involved testing several state-of-the-art models, including ResNet50, EfficientNetB3, and MobileNetV3. Despite challenges like low-contrast images and dataset imbalance, EfficientNetB3 and MobileNetV3 Models trained and validated through offline procedures were deployed to classify live image captures from a webcam (Table 2). This approach allowed for the assessment of each model's reliability, accuracy, and robustness when presented with practical variability, such as changing lighting conditions, different orientations, and subtle defect characteristics. Figure 14: Confusion matrices for binary classification using ResNet50, MobileNetV3-Large, and EfficientNetB3 on the test dataset (3690 samples). The top row of each matrix summarizes the true positives (TP), false positives (FP), false negatives (FN), and true negatives (TN). ResNet50 achieved the highest classification performance with only 1 false negative, while MobileNetV3 and EfficientNetB3 incurred 4 and 13 false negatives, respectively. We measured the model's inference speed and computational load under real-time conditions. Inference speed is reported in Frames Per Second (FPS) the number of video frames (images) processed per second. This throughput metric (FPS) directly reflects the system's real-time processing capability. Additionally, we compute the complexity model in terms of GFLOPs, which denotes the number of Giga (billion) Floating-point Operations required per inference. Reporting GFLOPs provides a hardware-agnostic measure of computational cost, allowing us to compare model efficiency independently of the test platform. By utilizing a webcam-based real-time application, this study provides an early-stage evaluation of model feasibility in practical environments. These insights can guide future efforts to fine-tune model architectures, develop ensemble techniques, and integrate these systems into production workflows. Ultimately, the goal is to enhance both accuracy and efficiency in defect detection systems for industrial applications. Figures 15 and 16 illustrate real-time inference outcomes using MobileNetV3-Large and EfficientNet-B3 models, respectively. MobileNetV3-Large consistently achieved high-confidence predictions (probabilities often exceeding 0.99) across different backgrounds and lighting conditions, highlighting its suitability for robust edge deployment in zero-defect manufacturing systems. EfficientNet-B3 similarly demonstrated reliability by accurately identifying defective plates with high confidence (0.98-1.00), even under varied lighting and positional challenge. During our real-time inference evaluations, we attempted to apply Post-Training Quantization (PTQ) to the trained model to reduce computational load and latency. However, the quantized (INT8) version of the model exhibited a substantial drop in prediction accuracy compared to the original full-precision model. In practice, we observed that Post-Training Quantization (PTQ) introduced significant degradation in the model's performance and was consistent with reports that quantizing both weights and activations can markedly impact accuracy.