Detect Printed Circuit Board (PCB) defects in real-time using YOLOv8, Computer Vision, and an interactive Streamlit Dashboard.
Industrial AI Dashboard for Automated PCB Quality Inspection
PCBInspect AI is an AI-powered industrial inspection system designed to automatically detect manufacturing defects on Printed Circuit Boards (PCBs).
The application combines YOLOv8 object detection, OpenCV image processing, and a modern Streamlit dashboard to provide fast, accurate, and interactive PCB inspection.
Instead of manually inspecting circuit boards, users can upload a PCB image (or capture one using a camera), and the system automatically:
- Detects PCB defects
- Draws bounding boxes
- Calculates confidence scores
- Displays inspection statistics
- Generates analytical charts
- Exports inspection reports (CSV & PDF)
The dashboard is designed to resemble an industrial quality inspection system used in electronics manufacturing.
β Industrial Dark-Themed Dashboard
β YOLOv8 Real-Time Object Detection
β Upload Image or Camera Capture
β Side-by-Side Image Comparison
β PCB Health Score
β Detection Confidence Analysis
β Severity Classification
β Detection Summary Table
β Interactive Charts
- Bar Chart
- Pie Chart
β Download Detection Image
β Export CSV Report
β Generate Professional PDF Report
β Responsive Streamlit UI
The trained model detects the following PCB manufacturing defects:
| Class | Description |
|---|---|
| Open | Broken electrical connection |
| Short | Unwanted electrical connection |
| Mouse Bite | Missing material on PCB edge |
| Spur | Small unwanted spurious copper projection |
| Spurious Copper | Excess spurious copper defect |
| Missing Hole | Small hole in spurious copper trace |
| Dashboard | Detection Results |
|---|---|
![]() |
![]() |
| Analytics | PDF Report |
|---|---|
![]() |
![]() |
PCB Image
β
βΌ
Streamlit Dashboard
β
βΌ
YOLOv8 Object Detector
β
βΌ
ββββββββββββββββββββββββββββββ
β Detect PCB Defects β
β β’ Open β
β β’ Short β
β β’ Mouse Bite β
β β’ Spur β
β β’ Spurious Copper β
β β’ Missing Hole β
ββββββββββββββββββββββββββββββ
β
βΌ
Detection Statistics
β
ββββββββββββββ΄βββββββββββββ
βΌ βΌ
Interactive Charts PDF & CSV Reports
PCB-Defect-Detection-AI/
β
βββ app.py
βββ detect.py
βββ train.py
βββ test_model.py
βββ requirements.txt
βββ README.md
βββ .gitignore
βββ dataset.yaml
βββ merged_dataset.yaml
βββ yolov8n.pt
β
βββ models/
β βββ best.pt
β
βββ src/
β βββ detector.py
β
βββ notebooks/
β βββ 01_YOLOv8_PCB_Defect_Detection_Training.ipynb
β
βββ results/
β βββ README.md
β βββ results.png
β βββ confusion_matrix.png
β βββ BoxF1_curve.png
β βββ BoxPR_curve.png
β βββ BoxP_curve.png
β βββ BoxR_curve.png
β
βββ assets/
βββ Project screenshots
git clone https://github.com/keerthy-gs/PCB-Defect-Detection-AI.git
cd PCB-Defect-Detection-AIpython -m venv .venv
.venv\Scripts\activatepython3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtstreamlit run app.pyThe dashboard will open automatically in your default browser.
| Category | Technology |
|---|---|
| Language | Python |
| Deep Learning | YOLOv8 |
| Framework | Streamlit |
| Computer Vision | OpenCV |
| Charts | Matplotlib |
| Data Analysis | Pandas |
| PDF Reports | ReportLab |
| QR Code | qrcode |
| Model Training | Ultralytics |
The PCB defect detection model is trained using a custom merged dataset of publicly available PCB inspection images.
The model is capable of detecting six different PCB defect categories in real time while maintaining fast inference speed.
The model was trained using a merged PCB defect dataset prepared from:
- DeepPCB
- TDD-PCB
- HRIPCB
- DsPCBSD+
The datasets were combined into one YOLO-format dataset with six defect classes:
- Open
- Short
- Mouse Bite
- Spur
- Spurious Copper
- Missing Hole
The training script expects the prepared merged dataset inside:
dataset/merged/
βββ images/
β βββ train/
β βββ val/
β βββ test/
βββ labels/
βββ train/
βββ val/
βββ test/
### Supported Defect Classes
| Class | Status |
|--------|--------|
| Open | β
|
| Short | β
|
| Mouse Bite | β
|
| Spur | β
|
| Spurious Copper | β
|
| Missing Hole | β
|
### Training Configuration
| Setting | Value |
|---|---|
| Model | YOLOv8n |
| Training images | 6,372 |
| Validation images | 1,511 |
| Image size | 640 Γ 640 |
| Batch size | 16 |
| Training method | Staged checkpoint fine-tuning |
| Total completed epochs | 53 |
[View the complete YOLOv8 training notebook](notebooks/01_YOLOv8_PCB_Defect_Detection_Training.ipynb)
### Final Validation Results
| Metric | Result |
|---|---:|
| Precision | 92.4% |
| Recall | 86.4% |
| mAP@50 | 92.3% |
| mAP@50β95 | 57.0% |
| Inference time | 2.3 ms per image |
### Training Result Graphs
#### Training Progress

#### Confusion Matrix

---
# π Detection Pipeline
```text
Input PCB Image
β
βΌ
Image Preprocessing
β
βΌ
YOLOv8 Object Detection
β
βΌ
Bounding Box Generation
β
βΌ
Confidence Score Calculation
β
βΌ
Dashboard Analytics
β
ββββββββββΊ Detection Table
ββββββββββΊ Health Score
ββββββββββΊ Charts
ββββββββββΊ CSV Report
ββββββββββΊ PDF Report
- π₯ Live webcam inspection
- πΉ Real-time production line monitoring
- π€ PCB defect severity prediction
- π Manufacturing analytics dashboard
- βοΈ Cloud deployment
- π± Mobile-friendly dashboard
- π Multi-PCB batch inspection
- π§ Defect trend analysis using AI
Contributions are always welcome!
If you'd like to improve this project:
- Fork the repository
- Create a new feature branch
- Commit your changes
- Push to your branch
- Open a Pull Request
Keerthy GS
Electronics and Communication Engineering (ECE)
Passionate about Artificial Intelligence, Computer Vision, Embedded Systems, and Software Development.
If you found this project useful,
please consider giving it a β on GitHub.
It helps others discover the project and motivates future improvements.
This project is licensed under the MIT License.
Feel free to use, modify, and distribute this project for educational and research purposes.



