betty0 commited on
Commit
08f7ff0
·
verified ·
1 Parent(s): 5079bc2

Upload best.pt/best.onnx/confusion matrix + model card (Phase 2 step 2.7)

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -0
  2. README.md +116 -0
  3. best.onnx +3 -0
  4. best.pt +3 -0
  5. confusion_matrix.png +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ confusion_matrix.png filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: agpl-3.0
3
+ library_name: ultralytics
4
+ pipeline_tag: object-detection
5
+ base_model: Ultralytics/YOLO26
6
+ tags:
7
+ - ultralytics
8
+ - yolo
9
+ - yolo26
10
+ - object-detection
11
+ - pcb
12
+ - defect-detection
13
+ - manufacturing
14
+ - aoi
15
+ model-index:
16
+ - name: pcb-defect-detection
17
+ results:
18
+ - task:
19
+ type: object-detection
20
+ dataset:
21
+ name: HRIPCB (PKU-Market-PCB), board-grouped split
22
+ type: hripcb
23
+ metrics:
24
+ - type: map50
25
+ value: 0.8390
26
+ name: "mAP50(B)"
27
+ - type: map50-95
28
+ value: 0.3881
29
+ name: "mAP50-95(B)"
30
+ ---
31
+
32
+ # PCB Bare-Board Defect Detection (YOLO26)
33
+
34
+ Ultralytics **YOLO26** (NMS-free, end-to-end detection head) fine-tuned to detect 6 classes of
35
+ bare printed-circuit-board defects: `missing_hole`, `mouse_bite`, `open_circuit`, `short`, `spur`,
36
+ `spurious_copper`.
37
+
38
+ - **Code, training notebooks, benchmark/ablation scripts**: [https://github.com/tun0000/pcb-defect-detection](https://github.com/tun0000/pcb-defect-detection)
39
+ - **Interactive demo**: [Space](https://huggingface.co/spaces/betty0/pcb-defect-detection)
40
+
41
+ ## Why this matters for AOI (Automated Optical Inspection)
42
+
43
+ Per-class **recall** approximates an inspection line's escape rate (missed defects that reach the
44
+ next stage); **precision** approximates the false-kill rate that drives manual re-inspection cost.
45
+ YOLO26's NMS-free head means the exported ONNX/TensorRT graph needs only a confidence-threshold
46
+ filter at inference time - no separate NMS step to tune or maintain.
47
+
48
+ ## Results (test split, never used for model selection)
49
+
50
+ This model was trained with a **board-grouped split** (8 boards train / 1 val / 1 test - the test
51
+ board's images never appear in training) rather than a random split, specifically to avoid the
52
+ background leakage that inflates numbers when a random split lets the same physical board's
53
+ background appear in both train and test.
54
+
55
+ | split strategy | mAP50 | mAP50-95 | test images | test instances |
56
+ |---|---|---|---|---|
57
+ | **board-grouped (this model)** | 0.8390 | 0.3881 | 120 | 358 |
58
+ | random (leakage control, separate model) | 0.9603 | 0.5082 | 72 | 284 |
59
+
60
+ The random-split control model scores 12.1 mAP50 points higher - that gap is
61
+ background leakage, not a better model. The board-grouped numbers above are the honest ones to
62
+ cite for this model's real-world generalization.
63
+
64
+ ### Per-class (board-grouped model, this repo)
65
+
66
+ | class | AP50 | AP50-95 | precision | recall |
67
+ |---|---|---|---|---|
68
+ | missing_hole | 0.9806 | 0.5825 | 0.9072 | 0.9667 |
69
+ | mouse_bite | 0.9362 | 0.4563 | 0.9821 | 0.9141 |
70
+ | open_circuit | 0.8963 | 0.4960 | 0.9584 | 0.7802 |
71
+ | short | 0.5649 | 0.1282 | 0.7245 | 0.6271 |
72
+ | spur | 0.8632 | 0.3982 | 0.9335 | 0.7024 |
73
+ | spurious_copper | 0.7929 | 0.2677 | 0.8896 | 0.6717 |
74
+
75
+ ## Usage
76
+
77
+ ```python
78
+ from huggingface_hub import hf_hub_download
79
+ from ultralytics import YOLO
80
+
81
+ path = hf_hub_download(repo_id="betty0/pcb-defect-detection", filename="best.pt")
82
+ model = YOLO(path)
83
+ results = model.predict("your_pcb_image.jpg", conf=0.25)
84
+ ```
85
+
86
+ An ONNX export (`best.onnx`, NMS-free e2e graph, `(1, 300, 6)` output = `[x1, y1, x2, y2, conf,
87
+ class_id]` in letterboxed 640x640 coordinates) is also included for torch-free deployment - see
88
+ the GitHub repo's `src/pcb_defect/e2e_onnx.py` for a minimal ONNX Runtime inference pipeline
89
+ (this is also what the Space above runs).
90
+
91
+ ## Training data
92
+
93
+ [HRIPCB / PKU-Market-PCB](https://www.kaggle.com/datasets/akhatova/pcb-defects) (693 images, 2,953 annotated defects, 10 template boards).
94
+ The Kaggle mirror used to obtain this data lists its license as "Unknown" - cite the original
95
+ paper:
96
+
97
+ > Huang, W., & Wei, P. (2019). A PCB Dataset for Defects Detection and Classification. arXiv:1901.08204 (https://arxiv.org/abs/1901.08204).
98
+
99
+ ## Limitations
100
+
101
+ - Only 10 unique template boards exist in the source dataset; 8 were used for training. Per-board
102
+ visual variance is high, so board-grouped val/test metrics carry more variance than a
103
+ larger-board-count dataset would.
104
+ - Defects are the dataset's synthetically-introduced defects, not naturally-occurring production
105
+ defects - real AOI imagery (lighting, focus, background) will differ (domain shift). Validate
106
+ against target production imagery before deployment.
107
+ - `short` and `spurious_copper` are the weakest classes (see per-class table above) even after
108
+ full training - this is a real, repeatable finding (confirmed independently in a separate SAHI
109
+ slicing-inference ablation), not measurement noise.
110
+ - Board-grouped metrics are **not directly comparable** to papers/notebooks reporting on a random
111
+ split of this same dataset (see the leakage comparison table above).
112
+
113
+ ## License
114
+
115
+ Code and weights are released under **AGPL-3.0** (required by Ultralytics' YOLO26 license).
116
+ Commercial use requires an [Ultralytics Enterprise License](https://www.ultralytics.com/license).
best.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:057c61dbd2745f59bd246effebf47a31686e95b0e2263610b0600664e5210fc5
3
+ size 38175508
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d2d1b6414e2dd9a1bfdd9d24d5c5a79c153dde03575e9ecb4e2de69c68a316c
3
+ size 20297541
confusion_matrix.png ADDED

Git LFS Details

  • SHA256: aae9f279946c79c901003d893477d9fd2ed750c93a8e6bec11cba726e346944e
  • Pointer size: 131 Bytes
  • Size of remote file: 176 kB