PCB 表面缺陷檢測:結果與決策板 PCB Surface-Defect Detection: Results & Decision Board

RF-DETR-Large(DINOv2 ViT-L + LW-DETR,端到端免 NMS)在 DsPCBSD+ 九類資料集上的三階段接力微調。這是研究展示,不是產線檢驗工具。 RF-DETR-Large (DINOv2 ViT-L + LW-DETR, end-to-end, no NMS) fine-tuned in a three-stage relay on the nine-class DsPCBSD+ dataset. A research showcase, not a production inspection tool.

GitHub · 程式碼與雙語文件code & docs Hugging Face · 權重weights Figshare · DsPCBSD+ (CC BY 4.0)

1. 主指標(A 級:pycocotools 端到端重評) 1. Headline metrics (grade A: pycocotools re-evaluation)

0.5397
mAP@0.5:0.95
來源 inference/infer/class_names.json from inference/infer/class_names.json
0.8677
mAP@0.5
2,051 張驗證影像2,051 val images
0.5710
mAP@0.75
4,092 個 GT 框4,092 GT boxes
0.6895
AR@100
召回上限,仍低於 AP@0.5recall ceiling, below AP@0.5

三種子實驗:seeds 0/1/2 在 cudnn.deterministic=True 下結果完全相同 → CI95 收斂為 0,代表的是推論可重複性,不是模型品質的不確定度。訓練迴路的 EMA 峰值 0.5411(v11a ep9)另行保留並標明定義,不冒充主指標。 Three-seed run: seeds 0/1/2 give identical results under cudnn.deterministic=True → CI95 collapses to 0, which evidences inference reproducibility, not uncertainty about model quality. The training-loop EMA peak 0.5411 (v11a ep9) is kept separately with its definition stated.

2. 逐類 AP(含類別頻率反差) 2. Per-class AP (and the frequency inversion)

AP@0.5 AP@0.5:0.95  ·  右側為驗證集 GT 框數(169–929,落差 5.5×) right column = val GT boxes (169–929, a 5.5× spread)

GT 數為作者紀錄(C→B 級):由 valid/_annotations.coco.json 統計,該標註檔未隨倉發布,但 eval_val.py 會在下載資料後逐類打印 GT 數,九類加總 4,092 與 A 級 evaluated_on 字串吻合。 GT counts are an author record (grade C→B): tallied from valid/_annotations.coco.json, which is not shipped; eval_val.py prints them per class after the data download, and the nine values sum to 4,092 — matching the grade-A evaluated_on string.

實例最多的 SP(929 框)AP@0.5:0.95 最低(0.4025),實例最少的 SH(169 框)卻是第二高(0.5805)。若瓶頸是稀有類樣本不足,SH 應該最差 → 這個資料集上的真正瓶頸是框的精確定位與類間形態重疊,不是樣本量。九類 AP@0.5 與 AP@0.5:0.95 平均差 0.3277(= 0.8670 − 0.5393;逐類差距取平均同為 0.3277):大致抓得到,框不準。 The most frequent class SP (929 boxes) has the lowest AP@0.5:0.95 (0.4025) while the rarest SH (169 boxes) ranks second (0.5805). If scarcity were the bottleneck SH would be worst → the real bottleneck is localisation precision and morphological overlap between classes, not sample count. Mean AP@0.5 minus AP@0.5:0.95 across classes is 0.3277 (= 0.8670 − 0.5393): roughly found, poorly boxed.

3. 三階段接力與天花板確認 3. Three-stage relay and ceiling confirmation

v8
起點接力relay start
再平衡 + COCO 轉換後的第一輪first round after re-balancing + COCO conversion
→
v9
0.49→0.51 等級range
首次超越當時內部 YOLO 基準(C 級作者紀錄)first pass of the internal YOLO baseline (grade-C record)
→
v11a
EMA 0.5411 · ep9
有效 10 epoch;重評主指標 0.5397ten logged epochs; headline re-evaluation 0.5397
單變數實驗Single-variable probe唯一變更Change結果(EMA)Result (EMA)判定Verdict
v10續跑 lr 1e-4continue at lr 1e-40.5410 / 0.5380 / 0.5392持平,lr 已過大flat, lr already too high
v11b解析度 640 → 768resolution 640 → 7680.5410 (僅 2 epoch)(2 epochs only)AP@0.5 升但框精度未跟上AP@0.5 up, localisation not
v12lr 5e-5 → 2e-5lr 5e-5 → 2e-50.5380 / 0.5362低於有效學習率below the effective lr

三個單變數實驗都未超越 v11a ep9 → 作者判定 0.5411 為此配方的天花板。這是「同配方、同資料、單變數」的內部結論,不構成對其他方法上限的主張。 None of the three single-variable probes beat v11a ep9 → the author concludes 0.5411 is the ceiling for this recipe. That is an internal, same-recipe conclusion and makes no claim about the limits of other methods.

4. 被封存的 11 條替代路徑(初步測試,非定論) 4. The eleven archived paths (preliminary, not verdicts)

#路徑/倉內實作Path / implementation初步結果Preliminary result為何不算定論Why it is not a verdict
1NWD · src/losses/nwd_loss.py未提升,以精度換極小召回no gain, traded precision for tiny recall早期 ablation,未在新配方重測early ablation, not re-run
2WIoU v3 · src/losses/iou_losses.pymAP 0.42825 (22 ep)未跑至收斂(基準 100 ep)not converged (baseline 100 ep)
3MPDIoU · src/losses/iou_losses.py框更緊但 mAP 無增益tighter boxes, no mAP gain同上脈絡,可重測same context, re-runnable
4SupCon · src/losses/supcon_head.pyλ∈{0.05…0.5} 未跨越 0.49never crossed 0.49grid 範圍窄、單次訓練narrow grid, single run
5768 + P2 · src/training/train.pymAP 0.22 崩潰collapse可能源自 LR/warmup 不匹配likely LR/warmup mismatch
6知識蒸餾Distillation · train.py --distill-modelNeck 4 vs 3 IndexError程式碼不相容,非架構否定code incompatibility
7VFL · src/losses/vfl_loss.pymAP 0.143 (10 ep)100 ep 版因 RAM OOM 未執行100-ep run blocked by OOM
8SAHI · src/evaluation/eval_sahi.py較基準 −23%−23% vs baseline未試 slice 160–200slices 160–200 untested
9D-FINE-S · src/training/train_dfine.pyep2 mAP 0.0009 即終止haltedlr 對 re-init 過高,無 warmup 補償lr too high for re-init
105-fold WBF · src/evaluation/eval_wbf_pycocotools.pymAP 0.4778 (−1.2%)僅 2 模型融合,多樣性不足;設計完成未執行only 2 models fused
11DINOv3 LTDETR · train_dinov3_pcb_v2.pyfp16 下 step 100 NaNNaN at step 100屬精度 bug 而非架構判定numerics bug, not an architecture verdict

5. 刻意不展示的對比 5. Comparisons deliberately not shown

內部起點記錄為 YOLO26x 100 epoch、mAP@0.5:0.95 = 0.4896,因此「+0.0515/+10.5%」這個數字過去確實出現在實驗紀錄裡。本倉不把它當展示主軸:YOLO26x 並非可驗證的公開發表模型,倉內 vs_yolo26x_baseline 欄位也明寫該對照未留存。對外只講自己量到的數字。 The internal starting point was logged as YOLO26x at 100 epochs with mAP@0.5:0.95 = 0.4896, so “+0.0515 / +10.5%” did appear in the experiment record. This repository does not present it as a headline: YOLO26x is not a verifiable published model, and the in-repo vs_yolo26x_baseline field states the comparison was not retained. Only self-measured numbers are shown.

6. 重現與驗證 6. Reproduction and checks

23
CI 測試總數CI tests in total
推論端 13(8 smoke + 5 webapp)+ 訓練端 1013 inference (8 smoke + 5 webapp) + 10 training-side
2
GitHub Actions jobsGitHub Actions jobs
核心 torch-free / CPU 推論端torch-free core / CPU inference
0
倉內影像與權重images or weights in git
資料自上游取,權重在 HFdata from upstream, weights on HF

逐指令重現(資料下載、再平衡、COCO 轉換、三階段接力、pycocotools 重評)見倉庫 docs/reproduction.md;架構取捨與測試地圖見 docs/architecture.md;數字來源分級見 docs/results.md。 Command-by-command reproduction (download, re-balancing, COCO conversion, the relay, the pycocotools re-evaluation) is in docs/reproduction.md; architecture trade-offs and the test map in docs/architecture.md; metric provenance grades in docs/results.md.