PCB Board Defects with Anomaly Detection

Heatmap anomaly localization Β· Reduced labeling Β· Production-friendly post-processing

Overview

This project targets defect detection on PCB boards (e.g., short circuits, missing/extra patterns, irregular traces) where labeled defect samples are limited. The system produces pixel-level anomaly heatmaps and a final OK/NG decision using robust scoring and post-processing.

🚨 Anomaly Detection πŸ—ΊοΈ Heatmap PyTorch OpenCV NumPy

Problem

  • Defects are rare and diverse β†’ hard to collect balanced labeled datasets.
  • Small defects need localization, not only classification.
  • Variations in lighting/PCB layouts can cause false alarms.

Solution

  • Train mainly on normal samples (unsupervised/weakly-supervised anomaly learning).
  • Generate anomaly heatmaps β†’ localize suspicious regions.
  • Compute defect score from ROI heatmap stats (max/mean) and apply tuned thresholds.
  • Post-processing: smoothing + morphology + connected components for stable decisions.

My Role

  • Designed the end-to-end anomaly pipeline producing heatmap-based defect localization.
  • Handled limited labels with anomaly learning strategy and strict validation.
  • Optimized post-processing and thresholds for robust decisions in production.

Implementation

Language: Python

Libraries:

PyTorch OpenCV NumPy

Outputs: Heatmap Β· Binary mask Β· Defect score Β· OK/NG decision

Deployment notes: ROI cropping + threshold tuning per PCB type for stable performance

Anomaly Map Gallery

Training Demo

Short clip showing the training process / anomaly map learning.