Skip to content

Tayne78/PCB-Vision-Inspector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PCB-Vision-Inspector

Automated Optical Inspection (AOI) system for detecting manufacturing defects on Printed Circuit Boards using YOLOv5.

Project Goal

The goal of this project was to build a working defect detection system for PCBs that could identify common manufacturing errors like missing holes, mouse bites, and short circuits. This is a typical problem in industrial quality control where manual inspection is slow and error-prone.

Why YOLOv5?

I chose YOLOv5 for several reasons:

  • Real-time capability: YOLO is designed for speed, which is important for production line integration
  • Transfer learning: Starting with pretrained weights (trained on COCO dataset) means I don't need millions of images to get good results
  • Easy to use: The Ultralytics implementation has a clean Python API and handles most of the complexity

I considered other approaches like Faster R-CNN or image classification, but object detection made more sense here since we need to know where the defect is, not just if there is one.

What I Learned

Transfer Learning really works. The model learned to detect PCB defects in just 100 epochs (~45 min) because it already knew how to recognize edges, textures, and shapes from the COCO pretraining. Training from scratch would have taken much longer and required more data.

Data quality matters more than quantity. The dataset has only ~1,400 training images, which is relatively small for deep learning. But because the images are well-labeled and consistent, the model still achieved >99% mAP.

Confidence thresholds are tricky. A threshold of 0.5 works well for most cases, but in production you'd want to tune this based on whether false positives or false negatives are worse for your application.

Model Performance

Metric Value
mAP@50 99.34%
mAP@50-95 92.88%
Precision 99.07%
Recall 98.41%

Training was done on an NVIDIA GeForce RTX 3060 with 100 epochs. This is not fully optimized – using a larger model or more epochs could improve results further.

Dataset

The dataset comes from Roboflow Universe (CC BY 4.0). To use this project, download the dataset and place it in data/:

data/
├── train/images/
├── train/labels/
├── valid/images/
├── valid/labels/
└── data.yaml

Installation

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Usage

Training

python train.py --model small --epochs 100

Inspection

python pcb_inspect.py --weights models/pcb_inspector_v1.pt --image path/to/pcb.jpg --output result.jpg

The script outputs a PASS/FAIL status and draws bounding boxes around detected defects.

What Could Be Improved

  • Negative samples: The dataset only contains images with defects. Adding defect-free PCBs would help reduce false positives.
  • More defect types: Real PCBs can have many more issues (solder bridges, tombstoning, wrong components). This model only covers three classes.
  • Model optimization: Exporting to ONNX or TensorRT would make inference faster for deployment.
  • Edge deployment: Would be interesting to run this on a Raspberry Pi or Jetson Nano for a standalone inspection station.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages