The objective of this project is to develop an automated PCB defect detection and classification system using image processing and deep learning techniques.
1.Template-based image subtraction for defect highlighting
2.Contour extraction for ROI detection
3.CNN-based classification for defect labeling
4.A Streamlit-based frontend enables users to upload PCB images, view annotated results, and export defect logs (CSV) and annotated images (JPG) for documentation and reporting.
πΉ Detect and localize PCB defects accurately
πΉ Classify defects into six predefined categories:
1.Missing Hole π³οΈ
2.Mouse Bite π
3.Open Circuit β‘
4.Short π
5.Spur π±
6.Spurious Copper π¦
πΉ Train a robust CNN model (EfficientNet) with high accuracy
πΉ Develop a user-friendly frontend for image upload and visualization
πΉ Implement a modular backend for image inference and processing
πΉ Enable export of annotated images, defect logs, and reports
DeepPCB dataset
Paired template and test images, with annotations for defects
1.Image alignment using ORB + RANSAC
2.Image subtraction for defect highlighting
3.Thresholding with Otsuβs method
4.ROI extraction for CNN input
PCB_DATASET/ βββ train/ β βββ missing_hole/ β βββ mouse_bite/ β βββ open_circuit/ β βββ short/ β βββ spur/ β βββ spurious_copper/ βββ val/ β βββ missing_hole/ β βββ mouse_bite/ β βββ open_circuit/ β βββ short/ β βββ spur/ β βββ spurious_copper/ βββ processed/ β βββ aligned_images/ β βββ difference_masks/ β βββ thresholded_masks/ β βββ defect_rois/ β βββ samples/ βββ docs/
Convert images to grayscale and normalize
Align test images with template using ORB feature matching + RANSAC
Apply Gaussian blur to reduce noise
Perform image subtraction to highlight defect regions
Detect defect contours using OpenCV
Crop Regions of Interest (ROI) for classification
Label and save ROIs for training the CNN
Backbone: EfficientNetB0 (pretrained on ImageNet)
Input: 128x128 pixels RGB
Loss: Categorical Cross-Entropy
Optimizer: Adam
Training:
1.Freeze EfficientNet base
2.Train custom classification head
3.Runtime data augmentation (rotation, flips, zooms)
Output: Defect type + confidence score
Modular Python functions handle:
Alignment and subtraction
ROI extraction
Model inference
Returns annotated images and defect logs
Built with Streamlit
Image upload for template & test PCBs
Annotated visualization of defects
Adjustable confidence threshold
Download annotated images & CSV logs
Dataset alignment, subtraction, thresholding, ROI extraction
Deliverables: Processed images, defect masks, ROI crops
Metrics: Alignment accuracy 100%, defect extraction 3β12 per image
CNN training with EfficientNet, validation & confusion matrix
Deliverables: Trained model, accuracy metrics (96% validation)
Metrics: High precision & recall, minimal misclassification
Streamlit frontend + modular backend pipeline
Deliverables: Interactive app with defect visualization
Metrics: Responsive UI, accurate defect detection, export-ready
Export results, optimize processing, final documentation
Deliverables: Final web app, annotated images, CSV logs, PDF report
Metrics: Fully functional system, ready for demonstration
| Metric | Description | Target |
|---|---|---|
| Detection Accuracy β | Correctly detected defects | β₯95% |
| Classification Accuracy π― | Correct defect type prediction | β₯95% |
| ROI Precision π | Bounding box coverage | High |
| Processing Time β±οΈ | Time per image | β€3s |
| Export Quality πΎ | Correct image & CSV generation | 100% |
| Area | Tools / Libraries |
|---|---|
| Image Processing πΌοΈ | OpenCV, Numpy |
| Deep Learning π€ | TensorFlow, Keras, PyTorch |
| Dataset π | DeepPCB |
| Frontend π | Streamlit |
| Backend π οΈ | Python, Modular Functions |
| Evaluation π | Accuracy, Confusion Matrix |
| Export π¦ | CSV, Annotated Image, PDF |
1.Annotated PCB images with bounding boxes
2.CSV logs of defects (type & confidence)
3.Visual reports and PDF export (optional)
4.Trained EfficientNet CNN model
5.Streamlit web application for inspection
1.Mount Google Drive (for Colab):
from google.colab import drive
drive.mount('/content/drive')
2.Install dependencies:
!pip install streamlit opencv-python-headless tensorflow pillow pandas
3.Run Streamlit app:
!streamlit run /content/drive/MyDrive/Akalya_PCB/milestone-4/app.py
4.Upload PCB image, adjust confidence, run inspection
5.View annotated output and download CSV/image
1)Real-time PCB inspection using camera input
2)Industrial deployment with higher resolution support
3)Semi-supervised learning for unannotated defects
4)Expanded defect categories and multi-board inspection
Akalya S. β SASTRA University
PCB Defect Detection & Classification System β Full Project (Milestone 1β4)
Transfer learning using EfficientNet π§
Patch-based scanning for high detection accuracy π
Modular backend + interactive frontend π₯οΈ
Exportable CSV and annotated images for professional reporting πΎ
Validation accuracy: 96% across six defect classes β
This documentation combines:
Milestone 1 (Dataset & preprocessing)
Milestone 2 (Model training & evaluation)
Milestone 3 (Frontend & backend integration)
Milestone 4 (Finalization, export, and presentation)