Skip to content

Latest commit

Β 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” PCBInspect AI

AI-Powered Industrial PCB Defect Detection System

Detect Printed Circuit Board (PCB) defects in real-time using YOLOv8, Computer Vision, and an interactive Streamlit Dashboard.

Python YOLOv8 Streamlit OpenCV License


Industrial AI Dashboard for Automated PCB Quality Inspection


πŸ“Œ Overview

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.


✨ Features

βœ… 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


🎯 Defects Detected

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 Preview

Home Dashboard

Dashboard Detection Results
Dashboard Detection
Analytics PDF Report
Analytics Report

πŸ—οΈ System Architecture

                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

πŸ“‚ Project Structure

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

βš™οΈ Installation

Clone the repository

git clone https://github.com/keerthy-gs/PCB-Defect-Detection-AI.git

cd PCB-Defect-Detection-AI

Create Virtual Environment

Windows

python -m venv .venv

.venv\Scripts\activate

Linux / macOS

python3 -m venv .venv

source .venv/bin/activate

Install Dependencies

pip install -r requirements.txt

Run the Application

streamlit run app.py

The dashboard will open automatically in your default browser.


πŸ› οΈ Tech Stack

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

πŸ“Š Model Performance

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.

Dataset

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

![YOLOv8 Training Results](results/results.png)

#### Confusion Matrix

![PCB Defect Confusion Matrix](results/confusion_matrix.png)

---

# πŸ”„ 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

πŸš€ Future Improvements

  • πŸŽ₯ 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

🀝 Contributing

Contributions are always welcome!

If you'd like to improve this project:

  1. Fork the repository
  2. Create a new feature branch
  3. Commit your changes
  4. Push to your branch
  5. Open a Pull Request

πŸ‘¨β€πŸ’» Author

Keerthy GS

Electronics and Communication Engineering (ECE)

Passionate about Artificial Intelligence, Computer Vision, Embedded Systems, and Software Development.

Connect with me


⭐ Support

If you found this project useful,

please consider giving it a ⭐ on GitHub.

It helps others discover the project and motivates future improvements.


πŸ“„ License

This project is licensed under the MIT License.

Feel free to use, modify, and distribute this project for educational and research purposes.


⭐ Thank you for visiting this repository! ⭐

Built with ❀️ using Python, YOLOv8, OpenCV and Streamlit.

About

AI-powered PCB defect detection using YOLOv8 with an interactive Streamlit dashboard for automated quality inspection.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages