noBSPCB: PCB Defect Detection with Monte Carlo Dropout

Model Description

This model is a modified YOLOv8n architecture with an additional Dropout layer (p=0.1) placed before the Detect head. It is designed for detecting 6 types of PCB defects:

  • missing_hole
  • mouse_bite
  • open_circuit
  • short
  • spur
  • spurious_copper

The model supports Monte Carlo Dropout (MCD) inference: running multiple forward passes with Dropout enabled to estimate epistemic uncertainty. The variance of confidence scores across passes indicates prediction reliability.

Training Dataset

  • Source: PCB Defect dataset (Norbert Elter, Peking University)
  • Size: 10,668 images
  • Split: train/val/test (8534/1066/1068)

Key Results

Metric Value
mAP@0.5 0.978
False Positives (on test set) 30
Recall 0.987
Inference time (CPU) 31 ms (baseline) / 628 ms (MCD)

The hybrid pipeline achieves 91.5% false positive reduction compared to baseline YOLOv8n.

Usage

Standard Inference

from ultralytics import YOLO

model = YOLO("oborxel/noBSPCB")
results = model("path/to/pcb_image.jpg")

Monte Carlo Dropout Inference

For uncertainty estimation, multiple passes are required:

from ultralytics import YOLO
import torch
import numpy as np

def enable_dropout(model):
    for m in model.model.modules():
        if isinstance(m, torch.nn.Dropout):
            m.train()

model = YOLO("oborxel/noBSPCB")
model.model.eval()
enable_dropout(model.model)

num_passes = 30
all_confs = []

for _ in range(num_passes):
    results = model("image.jpg", verbose=False)
    if results[0].boxes is not None:
        confs = results[0].boxes.conf.cpu().numpy()
        all_confs.extend(confs)

variance = np.var(all_confs) if all_confs else 0.0
print(f"Uncertainty (variance): {variance:.4f}")
print(f"Verdict: {'defect' if variance < 0.02 else 'uncertain'}")

License

MIT

Citation

If you use this model in your work, please cite:

@software{noBSPCB,
  author = {Chukhlov, Alexander},
  title = {noBSPCB: PCB Defect Detection with Monte Carlo Dropout},
  year = {2026},
  url = {https://github.com/ex-alander/noBSPCB}
}
Downloads last month
59
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support