This repository hosts a YOLOv8s object detection model fine-tuned on the DeepPCB PCB defect dataset for automated visual inspection of printed circuit boards. The model detects and localizes six common manufacturing defects from grayscale PCB imagery, making it suitable as a lightweight baseline for automated optical inspection (AOI), defect benchmarking, and industrial vision research.
Alongside the detection weights, this repository includes a companion knowledge-base module (inspector.py) that wraps the raw YOLO output with structured, defect-specific information — explanation, severity, likely root cause, potential impact, and recommended action — for each detected instance. This is a deterministic rules layer bundled with the model, not the neural network itself generating text; the detection weights (best.pt) only output class, bounding box, and confidence, exactly as a standard YOLOv8 model does.
Architecture: YOLOv8s (Ultralytics), single-stage anchor-free object detector
Base weights:yolov8s.pt (COCO-pretrained, then fine-tuned)
Parameters: ~11.1M
GFLOPs: ~28.4
Defect Classes
Class ID
Name
Description
0
copper
Excess/spurious copper residue on the board
1
mousebite
Small irregular notches along conductor edges
2
open
Break in a conductor path (broken circuit)
3
pin-hole
Small void/hole defect in the copper trace
4
short
Unintended connection between two conductors
5
spur
Unwanted protruding copper extension
Evaluation Results
Dataset Split
Split
Images
Used For
Train
1,050
Model fine-tuning
Validation
150
Metric reporting (below)
Test
300
Qualitative inference / sample predictions
All metrics below are computed on the validation split (150 images, 1,003 annotated instances). The test split (300 images) was used only for qualitative inference — the sample detections shown further down are drawn from it.
Each pair shows the raw input image (left) and the model's predicted output with bounding boxes and confidence scores (right). Samples are drawn from the test split.
Automated Optical Inspection (AOI) integration for PCB manufacturing lines
Pre-screening boards before manual QA review, reducing inspector workload
Defect-rate tracking and analytics across production batches
Research baseline for PCB defect detection benchmarking
Educational/demo use for object detection in industrial inspection contexts
Generating structured, actionable inspection reports (via inspector.py) for non-expert reviewers
Limitations
This model was trained on DeepPCB grayscale linear-scan images and has not been validated on RGB PCB images or other imaging modalities.
Performance may degrade under distribution shifts such as different board layouts, camera setups, illumination conditions, or image resolutions.
Localization performance at stricter IoU thresholds is weaker for thin, elongated defects such as open and short, as reflected in their lower mAP@0.5:0.95 scores.
The inspector.py explanations, severities, root causes, impacts, and actions are drawn from a static, hand-curated knowledge base per defect class — they are general guidance, not image-specific diagnosis, and do not account for defect size, position, or board context.
The model should be treated as a research / baseline AOI model, not a production-ready inspection system, unless further validated on real manufacturing data.
Repository Contents
best.pt — best fine-tuned YOLOv8s weights
inspector.py — companion module providing severity, root cause, impact, and recommended action per detected defect
sample*_input.jpg / sample*_predicted.jpg — example qualitative detections (from test split)
README.md — model documentation and usage instructions
Intended Role in Project
This model is Stage 1 of a two-stage PCB defect detection effort:
Stage 1 (this repo): YOLOv8s fine-tuned on DeepPCB — 6 defect classes, clean grayscale images, used as a baseline and pipeline validation stage.
Stage 2 (in progress): YOLOv8m fine-tuned on DSPCBSD+ — 9 defect classes, larger and more challenging dataset with smaller, imbalanced defect instances.
The two models are intended to be used together or compared, with this repo serving as the simpler, faster baseline.