Skip to content

Yani-Studio/pcb_defects_classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔍 PCB Defects Classification: High-Precision Entropy-based Ensemble (99.80% Accuracy)

Python TensorFlow Hardware Accuracy

This repository implements an advanced deep learning pipeline tailored for high-precision detection and classification of defects in Printed Circuit Boards (PCB). By conducting a Massive Ablation Study on 50+ CNN architectures and integrating a novel Entropy-based Uncertainty Exclusion strategy, the framework achieves a near-perfect production-ready accuracy of 99.80%.


⚠️ Copyright Notice Copyright (c) 2026 Kang Gyu Min. All rights reserved.


📊 Performance Benchmarks

Elite Model Leaderboard

The automated pipeline systematically evaluates the top 10 SOTA vision lineages to statistically determine the optimal backbones for the specialized PCB feature space.

Rank Architecture Accuracy Status
🏆 ResNet50_V1 + MobileNet_V1 0.9980 Best Ensemble (Proposed)
1 ResNet50_V1 0.9960 Elite Backbone
2 MobileNet_V1 0.9955 High-Efficiency SOTA
3 MobileNetV2 0.9935 Balanced Model
4 EffNetB1 0.9900 Lightweight Alternative

Detailed Classification Report (Entropy Ensemble)

Defect Type Precision Recall F1-Score Support
copper / spur 1.0000 1.0000 1.0000 619
mousebit 0.9949 1.0000 0.9975 393
open 1.0000 0.9948 0.9974 388
pin-hole / short 0.9967 0.9967 0.9967 601
Weighted Avg 0.9980 0.9980 0.9980 2001

🚀 Key Technical Features

1. Strategic 3-Stage Training (Overnight Full-Course)

To maximize transfer learning efficiency and prevent catastrophic forgetting, every candidate model undergoes a rigorous three-phase training protocol:

  • Phase 1: Classifier Foundation (Base Frozen) Backbone weights are strictly locked while training a custom classification head to establish robust, high-level feature mapping.
  • Phase 2: Precision Fine-tuning (Partial Unfreeze) The top 50 layers of the backbone are unfrozen to adapt mid-level feature representations to domain-specific PCB patterns.
  • Phase 3: Deep Optimization (Large Unfreeze) Up to 75 layers are unfrozen utilizing a CosineDecay scheduler (initial LR 1e-5) to achieve smooth convergence and flawless parameter alignment.

2. Image Preprocessing & Entropy Exclusion

  • Input Resolution Optimization: All images are dynamically resized and normalized to 224x224 for optimized, high-throughput feature extraction through SOTA CNN backbones.
  • Uncertainty Filtering: The system calculates the Shannon Entropy of predictive probabilities across models and adaptively adopts the final decision from the network demonstrating the lowest classification uncertainty.

3. Hardware-Aware Memory Optimization (M5 Silicon)

Engineered specifically for stable, extensive overnight training runs on local hardware configurations such as the Apple Silicon M5 (24GB Unified Memory):

  • Unified Memory Management: Implemented explicit K.clear_session() and gc.collect() infrastructure loops between each of the 50+ iterative model evaluations to completely eradicate memory leaks.
  • Label Smoothing (0.1): Integrated directly into the cross-entropy loss function to significantly improve generalization and absorb industrial-grade image or labeling noise.

🌌 Result Visualization

1. End-to-End Defect Detection Result Samples

Detection Sample 1 Detection Sample 2
Real-time inference samples demonstrating high-precision bounding box localization.

2. Defect Analysis & Substrate Inspection

Error Defect Analysis Substrate Comparison
Detailed view of specific defect patterns and clean substrate comparison.

Note

💡 Error Analysis Deep-Dive > Achieved an exceptional 99.8% accuracy using Sugeno Ensembles and Stacking. Intensive error analysis of the 4 misclassified samples revealed highly complex edge-case defects—specifically, mousebits evolving into open circuits and highly irregular shorts. This firmly validates that the model’s Feature Extraction capabilities are fully production-ready, concluding that the remaining 0.2% variance is a Data-centric AI challenge requiring refined labeling standards rather than further architectural tuning.

3. Final Confusion Matrix (Entropy-based Ensemble)

Final Confusion Matrix
Final evaluation on the test set using the Entropy-based Ensemble method (Accuracy: 99.80%).

4. 3D t-SNE Feature Space Visualization

3D t-SNE Projections
High-dimensional feature separation demonstrating robust model discriminability and distinct class clusters.


📂 Repository Structure

📦 pcb_defects_classification
 ┣ 📂 PCBData                 # Dataset directory (Resized to 224x224)
 ┣ 📂 output/                 # Prediction Probabilities, Checkpoints & Metrics
 ┃  ┣ 📂 ensemble/            # Final Entropy-based ensemble results
 ┃  ┣ 📂 single_model/        # Individual backbone performance reports
 ┃  ┗ 📂 visualization/       # 3D projections, confusion matrices & detection samples
 ┣ 📜 train_model.ipynb       # Core Pipeline Notebook: 3-Stage Training Execution
 ┗ 📜 README.md               # Project Documentation

About

High-precision deep learning ensemble pipeline for PCB defect classification (99.80% accuracy)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors