betty0's picture
Upload best.pt/best.onnx/confusion matrix + model card (Phase 2 step 2.7)
08f7ff0 verified
|
Raw
History Blame Contribute Delete
4.9 kB
---
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**: [https://github.com/tun0000/pcb-defect-detection](https://github.com/tun0000/pcb-defect-detection)
- **Interactive demo**: [Space](https://huggingface.co/spaces/betty0/pcb-defect-detection)
## 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="betty0/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).