CoolFace
Modelpublic

steven0226/pcb-defect-detection

sourceHugging Faceagpl-3.0updated 19d agoView on Hugging Face
0likes41downloads
Model Card

PCB Bare-Board Defect Detection (YOLO26)

Ultralytics YOLO26 (NMS-free, end-to-end detection head) fine-tuned to detect 6 classes of bare printed-circuit-board defects: missing_hole, mouse_bite, open_circuit, short, spur, spurious_copper.

  • Related source repository: <https://github.com/kuotunyu/pcb-defect-detection> — the current, leakage-aware paired-protocol study with its own release evidence. These weights predate that study and are not its release artifact; treat this card's numbers as this model's own record only.
  • Interactive demo: none deployed (no Space). GitHub kuotunyu and Hugging Face steven0226 are the same author.

Why this matters for AOI (Automated Optical Inspection)

Per-class recall approximates an inspection line's escape rate (missed defects that reach the next stage); precision approximates the false-kill rate that drives manual re-inspection cost. YOLO26's NMS-free head means the exported ONNX/TensorRT graph needs only a confidence-threshold filter at inference time - no separate NMS step to tune or maintain.

Results (test split, never used for model selection)

This model was trained with a board-grouped split (8 boards train / 1 val / 1 test - the test board's images never appear in training) rather than a random split, specifically to avoid the background leakage that inflates numbers when a random split lets the same physical board's background appear in both train and test.

split strategymAP50mAP50-95test imagestest instances
board-grouped (this model)0.83900.3881120358
random (leakage control, separate model)0.96030.508272284

The random-split control model scores 12.1 mAP50 points higher - that gap is background leakage, not a better model. The board-grouped numbers above are the honest ones to cite for this model's real-world generalization.

Per-class (board-grouped model, this repo)

classAP50AP50-95precisionrecall
missing_hole0.98060.58250.90720.9667
mouse_bite0.93620.45630.98210.9141
open_circuit0.89630.49600.95840.7802
short0.56490.12820.72450.6271
spur0.86320.39820.93350.7024
spurious_copper0.79290.26770.88960.6717

Usage

python
from huggingface_hub import hf_hub_download
from ultralytics import YOLO

path = hf_hub_download(repo_id="steven0226/pcb-defect-detection", filename="best.pt")
model = YOLO(path)
results = model.predict("your_pcb_image.jpg", conf=0.25)

An ONNX export (best.onnx, NMS-free e2e graph, (1, 300, 6) output = [x1, y1, x2, y2, conf, class_id] in letterboxed 640x640 coordinates) is also included for torch-free deployment - see the GitHub repo's src/pcb_defect/e2e_onnx.py for a minimal ONNX Runtime inference pipeline (this is also what the Space above runs).

Training data

HRIPCB / PKU-Market-PCB (693 images, 2,953 annotated defects, 10 template boards). The Kaggle mirror used to obtain this data lists its license as "Unknown" - cite the original paper:

Huang, W., & Wei, P. (2019). A PCB Dataset for Defects Detection and Classification. arXiv:1901.08204 (https://arxiv.org/abs/1901.08204).

Limitations

  • Only 10 unique template boards exist in the source dataset; 8 were used for training. Per-board visual variance is high, so board-grouped val/test metrics carry more variance than a larger-board-count dataset would.
  • Defects are the dataset's synthetically-introduced defects, not naturally-occurring production defects - real AOI imagery (lighting, focus, background) will differ (domain shift). Validate against target production imagery before deployment.
  • short and spurious_copper are the weakest classes (see per-class table above) even after full training - this is a real, repeatable finding (confirmed independently in a separate SAHI slicing-inference ablation), not measurement noise.
  • Board-grouped metrics are not directly comparable to papers/notebooks reporting on a random split of this same dataset (see the leakage comparison table above).

License

Code and weights are released under AGPL-3.0 (required by Ultralytics' YOLO26 license). Commercial use requires an Ultralytics Enterprise License.