Object Detection
ultralytics
ONNX
yolo
yolo26
pcb
defect-detection
manufacturing
aoi
Eval Results (legacy)
Instructions to use steven0226/pcb-defect-detection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use steven0226/pcb-defect-detection with ultralytics:
# Couldn't find a valid YOLO version tag. # Replace XX with the correct version. from ultralytics import YOLOvXX model = YOLOvXX.from_pretrained("steven0226/pcb-defect-detection") source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
File size: 4,813 Bytes
99c7519 09fc563 baf9feb 99c7519 09fc563 99c7519 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | ---
license: agpl-3.0
library_name: ultralytics
pipeline_tag: object-detection
base_model: Ultralytics/YOLO26
tags:
- ultralytics
- yolo
- yolo26
- object-detection
- pcb
- defect-detection
- manufacturing
- aoi
model-index:
- name: pcb-defect-detection
results:
- task:
type: object-detection
dataset:
name: HRIPCB (PKU-Market-PCB), board-grouped split
type: hripcb
metrics:
- type: map50
value: 0.8390
name: "mAP50(B)"
- type: map50-95
value: 0.3881
name: "mAP50-95(B)"
---
# 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`.
- **Code, training notebooks, benchmark/ablation scripts**: [source repository publication pending)
- **Interactive demo**: [Space](Space deployment pending)
## 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 strategy | mAP50 | mAP50-95 | test images | test instances |
|---|---|---|---|---|
| **board-grouped (this model)** | 0.8390 | 0.3881 | 120 | 358 |
| random (leakage control, separate model) | 0.9603 | 0.5082 | 72 | 284 |
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)
| class | AP50 | AP50-95 | precision | recall |
|---|---|---|---|---|
| missing_hole | 0.9806 | 0.5825 | 0.9072 | 0.9667 |
| mouse_bite | 0.9362 | 0.4563 | 0.9821 | 0.9141 |
| open_circuit | 0.8963 | 0.4960 | 0.9584 | 0.7802 |
| short | 0.5649 | 0.1282 | 0.7245 | 0.6271 |
| spur | 0.8632 | 0.3982 | 0.9335 | 0.7024 |
| spurious_copper | 0.7929 | 0.2677 | 0.8896 | 0.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](https://www.kaggle.com/datasets/akhatova/pcb-defects) (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](https://www.ultralytics.com/license).
|