Comparative Analysis of a Custom CNN and MobileNetV2 for Automated PCB Defect Classification
Printed Circuit Boards (PCBs) are critical components in modern electronic devices. Manufacturing defects such as missing holes, mouse bites, open circuits, shorts, spurs, and spurious copper can significantly affect product quality and reliability.
This project develops an automated PCB defect classification system using Deep Learning. A Custom CNN model is implemented as a baseline and compared against a MobileNetV2 Transfer Learning model to evaluate the effectiveness of transfer learning for industrial defect inspection.
MobileNetV2
| Model | Accuracy |
|---|---|
| Custom CNN | 84.60% |
| MobileNetV2 | 97.49% |
The dataset consists of PCB defect images generated from YOLO-annotated PCB inspection data.
| Dataset Split | Samples |
|---|---|
| Train | 12,991 |
| Validation | 1,595 |
| Test | 1,662 |
| Total | 16,248 |
- Missing Hole
- Mouse Bite
- Open Circuit
- Short
- Spur
- Spurious Copper
The project follows the following workflow:
- Data Preparation and Cleaning
- Image Preprocessing and Augmentation
- Custom CNN Development
- MobileNetV2 Transfer Learning
- Model Evaluation
- Error Analysis
- Prediction Confidence Analysis
- Three Convolutional Blocks
- Batch Normalization
- Max Pooling
- Dropout Regularization
- Softmax Classification Layer
- Pre-trained ImageNet Weights
- Transfer Learning
- Fine-Tuning Strategy
- Global Average Pooling
- Dense Classification Head
| Model | Accuracy | Precision | Recall | F1-Score |
|---|---|---|---|---|
| Custom CNN | 84.60% | 84.95% | 84.60% | 84.69% |
| MobileNetV2 | 97.49% | 97.50% | 97.49% | 97.49% |
The MobileNetV2 model significantly outperformed the Custom CNN, demonstrating the effectiveness of transfer learning for PCB defect classification.
Prediction confidence analysis was performed on unseen PCB defect images to evaluate model reliability.
The MobileNetV2 model correctly classified PCB defects with high confidence, providing additional evidence of robust feature learning.
PCB-Defect-Detection-Using-CNN
│
├── README.md
├── requirements.txt
│
├── notebooks/
│ └── pcb-defect-detection-using-cnn.ipynb
│
├── figures/
│ ├── project figures and visualizations
│
├── data/
│ └── table_dataset_summary.csv
│
└── report/
- Open the notebook.
- Enable GPU acceleration.
- Add the required datasets.
- Run all cells.
git clone https://github.com/your-username/PCB-Defect-Detection-Using-CNN.git
cd PCB-Defect-Detection-Using-CNN
pip install -r requirements.txt- Python
- TensorFlow
- Keras
- NumPy
- Pandas
- Matplotlib
- Scikit-Learn
- OpenCV
- Kaggle
This project demonstrates that Transfer Learning can significantly improve PCB defect classification performance compared to a CNN trained from scratch. MobileNetV2 achieved 97.49% classification accuracy and substantially reduced classification errors, making it a strong candidate for automated PCB inspection systems.
Keshava Mani Dheekshith Reddy Naredla
Machine Learning Project


