Downloads · 30 days
50
18% of all-time downloads
Janani-V/pcb-defect-yolov8m-dspcbsd
pcb-defect-yolov8m-dspcbsd is a object detection model from Janani-V. Use it when you need objects located in an image. It is set up for ultralytics. The card lists the license as mit.
- Model: YOLOv8m - Task: PCB defect detection (object detection) - Dataset: DsPCBSD+ (via Roboflow export) - Classes: 9 defect categories - Framework: Ultralytics YOLOv8 - Input size: 640 × 640 - Training hardware: Go…
Downloads · 30 days
50
18% of all-time downloads
All-time downloads
273
Public
Repo size
52.5 MB
Likes
0
Public
Click a slice to open those files.
.pt52 MB · 99%
From the Hugging Face model README
inspector.py — adds severity, root cause, impact, and recommended action per detection🔍 Part of a two-stage project: see also Janani-V/pcb-defect-yolov8s-deeppcb — a simpler 6-class baseline on DeepPCB.
Note: These two models were trained on different datasets (DeepPCB vs. DsPCBSD+) with different class counts and difficulty levels, so this is not a strictly apples-to-apples benchmark — it's meant to help you choose the right model for your use case.
| Stage 1: YOLOv8s | Stage 2: YOLOv8m | |
|---|---|---|
| Model | pcb-defect-yolov8s-deeppcb | pcb-defect-yolov8m-dspcbsd (this repo) |
| Dataset | DeepPCB | DsPCBSD+ |
| Classes | 6 | 9 |
| Train / Val images | 1,050 / 150 | 8,208 / 2,051 |
| Total annotations | ~1,003 (val) | 4,092 (val) |
| Image source | Grayscale linear-scan CCD | RGB copper-surface crops (226×226 native) |
| Model size | YOLOv8s (~11.1M params) | YOLOv8m (~25.9M params) |
| [email protected] | 0.985 | 0.839 |
| [email protected]:0.95 | 0.734 | 0.508 |
| Precision | 0.961 | 0.807 |
| Recall | 0.963 | 0.810 |
| Best-performing class | copper (mAP50 0.994) | hole_breakout (mAP50 0.984) |
| Weakest-performing class | short (mAP50-95 0.639) | conductor_foreign_object (mAP50 0.701) |
DsPCBSD+ is a meaningfully harder benchmark than DeepPCB:
conductor_scratch and conductor_foreign_object, which vary widely in size, shape, and appearanceA lower mAP on DsPCBSD+ does not mean this model is "worse" — it reflects a genuinely harder detection problem with more real-world defect diversity.
This repository hosts a YOLOv8m object detection model fine-tuned on DsPCBSD+, a large-scale (10,259 image, 20,276 annotation) PCB surface defect dataset covering 9 defect categories across conductors, holes, and base material. This is a substantially harder detection task than DeepPCB — defects are smaller, more varied in shape/scale, and the class distribution is imbalanced.
Alongside the detection weights, this repository includes inspector.py, a companion knowledge-base module providing explanation, severity, root cause, impact, and recommended action per detected defect. This is a deterministic rules layer, not the model itself generating text — best.pt outputs class, bounding box, and confidence only.
Architecture: YOLOv8m (Ultralytics), single-stage anchor-free object detector
Base weights: yolov8m.pt (COCO-pretrained, then fine-tuned)
| Class | Abbreviation (paper) | Description |
|---|---|---|
short | SH | Unintended connection between conductors |
spur | SP | Sharp protrusion off a conductor edge |
spurious_copper | SC | Unwanted copper residue |
open | OP | Break in a conductor path |
mouse_bite | MB | Small notch/crack at conductor edge |
hole_breakout | HB | Hole center deviates from bounding pad |
conductor_scratch | CS | Scratch on copper wire/surface |
conductor_foreign_object | CFO | Contamination on a conductor |
base_material_foreign_object | BMFO | Contamination on bare substrate |
Validation set: 2,051 images, 4,092 annotated instances (official 8:2 train/val split).
| Metric | Value |
|---|---|
| Precision | 0.807 |
| Recall | 0.810 |
| [email protected] | 0.839 |
| [email protected]:0.95 | 0.508 |
| Class | Images | Instances | Precision | Recall | mAP50 | mAP50-95 |
|---|---|---|---|---|---|---|
| short | 126 | 169 | 0.875 | 0.882 | 0.906 | 0.592 |
| spur | 430 | 929 | 0.852 | 0.786 | 0.850 | 0.389 |
| spurious_copper | 245 | 285 | 0.757 | 0.779 | 0.822 | 0.507 |
| open | 274 | 338 | 0.803 | 0.855 | 0.889 | 0.532 |
| mouse_bite | 391 | 546 | 0.851 | 0.773 | 0.823 | 0.410 |
| hole_breakout | 271 | 608 | 0.917 | 0.977 | 0.984 | 0.830 |
| conductor_scratch | 279 | 448 | 0.696 | 0.695 | 0.731 | 0.456 |
| conductor_foreign_object | 309 | 423 | 0.693 | 0.667 | 0.701 | 0.408 |
| base_material_foreign_object | 305 | 346 | 0.817 | 0.878 | 0.848 | 0.449 |



Sample 1
<table> <tr><th>Input</th><th>Prediction</th></tr> <tr><td><img src="sample1_input.jpg" width="300"/></td><td><img src="sample1_predicted.jpg" width="300"/></td></tr> </table>Sample 2
<table> <tr><th>Input</th><th>Prediction</th></tr> <tr><td><img src="sample2_input.jpg" width="300"/></td><td><img src="sample2_predicted.jpg" width="300"/></td></tr> </table>| Parameter | Value |
|---|---|
| Base model | yolov8m.pt (COCO-pretrained) |
| Dataset | DsPCBSD+ (9 classes), via Roboflow export |
| Epochs | 50 |
| Image size | 640 × 640 |
| Batch size | 16 |
| Scheduler | Cosine LR |
| Hardware | Google Colab, Tesla T4 GPU |
from huggingface_hub import snapshot_download
import sys
local_dir = snapshot_download(repo_id="Janani-V/pcb-defect-yolov8m-dspcbsd")
sys.path.append(local_dir)
from inspector import PCBDefectInspector
inspector = PCBDefectInspector(weights_path=f"{local_dir}/best.pt")
result = inspector.inspect("your_pcb_image.jpg")
print(result["summary"])
for f in result["findings"]:
print(f["class"], "-", f["severity"], "-", f["action"])
conductor_foreign_object (mAP50 0.701) and conductor_scratch (mAP50 0.731) are the weakest classes — these defects have high intra-class variability in size, shape, and color, making them inherently harder to detect consistently.inspector.py explanations are drawn from a static, hand-curated knowledge base — general guidance, not image-specific diagnosis.best.pt — fine-tuned YOLOv8m weightsinspector.py — companion module with severity/root-cause/impact/action knowledge basemetrics_chart.png — per-class performance chartresults.png — training loss/metric curves across all epochsconfusion_matrix.png — normalized confusion matrix across all 9 classessample*_input.jpg / sample*_predicted.jpg — example detectionsREADME.md — this fileFine-tuned and maintained by Janani-V.
Original dataset: Lv, S. et al. "A dataset for deep learning based detection of printed circuit board surface defect." Scientific Data 11, 811 (2024). https://doi.org/10.1038/s41597-024-03656-8
Dataset access: janani-v-sdspd/dspcbsd-plus on Roboflow Universe
Model architecture: Jocher, G. et al. — Ultralytics YOLOv8: https://github.com/ultralytics/ultralytics